A phone shows a map of Pennsylvania's 17th congressional district.Mark Makela / Reuters

Across the nation, judges are discovering that if you look for it, partisan gerrymandering actually is all around you.

Courts have historically been reluctant to strike down redistricting plans on the basis of political bias—unwilling to appear to be favoring one party—but Monday afternoon, the Pennsylvania state supreme court ruled that the state’s maps for U.S. House violate the state constitution’s guarantees of free expression and association and of equal protection.

That follows a ruling earlier this month in North Carolina, in which a federal court struck down the state’s maps, the first time a federal court had ruled a redistricting plan represented an unconstitutional gerrymander. The decision was stayed by the U.S. Supreme Court, which is already considering another partisan gerrymandering case from Wisconsin. The court has also agreed to hear another case, from Maryland, and rejected a case from Texas on procedural grounds.

The Pennsylvania case may be at once the most important in the immediate term and least important in the long term. That’s because it is based on the state constitution, which limits its reach but also means it is more likely to remain in place. Republican legislators vowed to seek a stay from the U.S. Supreme Court, while Democratic lawyers argued there was no path to the high court.

If it stands, however, it could be a huge gift to Democrats in 2018. There are 18 House districts in Pennsylvania. Twelve are held by Republicans and five by Democrats, and the 18th was held by a Republican until he resigned in October in a sex scandal. (Monday’s ruling will not affect a hotly anticipated special election in March.) In 2016, Donald Trump surprised many observers by winning Pennsylvania, but all five statewide elected offices are held by Democrats. The Keystone State has often landed on lists of the worst district maps in the country.

“It’s been a very effective partisan gerrymander,” said Michael Berkman, director of the McCourtney Institute for Democracy at Penn State. “Republicans have had a challenging time if you look at it at the state level. Democrats clearly hold an advantage in the state, but they have just been destroyed in the legislature.”

Given the scrutiny of the maps, Monday’s decision did not come as a complete shock. A separate challenge, also on partisan gerrymandering, was tossed out in federal court in December, but Democrats hold an edge on the state supreme court. The court issued a short decision Monday, with a fuller discussion to follow; two judges dissented, and a third dissented in part and concurred in part.

There are no new maps yet—in fact, the state supreme court ordered a very short timeline for the state legislature to draw new ones, and threatened to draw its own if lawmakers do not—so it’s hard to tell how great an effect the ruling might have. But it’s clear who will benefit.

“I think the Democrats would be optimistic that they would have a reasonable chance of picking up” a few seats, said Terry Madonna, a political scientist at Franklin and Marshall College. Estimates range from one to two spots to as many as four or five. It’s not just that the new maps will be less slanted toward Republicans. It also means that some current Republicans will lose some advantage of incumbency in their districts.

That all comes at the worst possible time for the GOP. Polling data and the pace of retirements from Congress, as well as President Trump’s terrible approval ratings, all suggest that 2018 could be a Democratic wave election.

“The kind of energy you’re seeing elsewhere we’re seeing here as well,” Berkman said.

There are peculiar dynamics specific to Pennsylvania that hurt Republicans, too. The state is a microcosm of national political dynamics, with traditionally Republican suburban areas, which handed Democrats big wins in 2017 special elections across the country, trending toward the Democratic Party, and traditionally Democratic white, blue-collar voters sliding toward the Republican Party.

In the 18th district, vacated by Tim Murphy’s resignation, Democrats are posing a staunch challenge, but it won’t be the only open seat this fall. Charlie Dent, a moderate GOP critic of Donald Trump, is retiring, and so is Bill Shuster. Over the weekend, The New York Times reported on Pat Meehan settling a sexual-harassment suit; other members in his position have resigned or announced plans to retire.

That doesn’t mean the state is likely to end up with a 9-9 delegation. The Democratic Party is hobbled by its strength in urban centers, which tends to produce districts packed with its voters. The eventual split is likely to get closer to even, though.

The Pennsylvania case shares several key characteristics with the Wisconsin and North Carolina cases. All three seek outcomes that would help Democrats and hurt Republicans. Second, all three argue that voters have been deprived of their rights to free speech, free association, and equal protection by virtue of being targeted for their choice to vote for the Democratic Party, which they say resulted in their being drawn into districts that reduced their voting power.

Third, all three represent a new movement toward quantifying the influence of partisan gerrymandering. One metric is the “efficiency gap,” a measure of how many votes for a candidate are wasted—either the number of votes in excess of what the candidate needs to win, common when voters backing a candidate are packed into a district, or the number of votes cast for the loser, when that candidate’s supporters are dispersed. Another method of quantifying the impact of gerrymandering is to run random simulations of maps to show how far the existing maps sit outside normal distributions.

Although districts are sometimes struck down for gerrymandering on the basis of race, courts have been reluctant to declare gerrymanders unconstitutional on partisan bounds because such rulings thrust the judiciary into the middle of partisan battles. Since legislatures are, in most states, entitled to draw the lines, it’s always been assumed that they will draw lines that give their own party an edge. The question is whether they can go too far. In the North Carolina case, the legislature protested, “How much politics is too much politics in redistricting?” The goal of the metrics is to answer that question, giving judges empirical data on which to base their decisions.

Either because of that new approach, or because ever-more-creative redistricting efforts have produced maps carved up into fantastical districts that would make Elbridge Gerry himself blush, judges suddenly seem to be more receptive to such arguments.

“You’re seeing how much turmoil there is now in the lower federal courts, and how many federal judges believe the time has come for the courts to impose substantial limits,” Richard Pildes, a law professor at New York University, recently told the Times.

The U.S. Supreme Court stayed the North Carolina decision while it considers the pending cases, and it seems unlikely (though not impossible) that the justices would render a ruling in time to affect 2018 races in Wisconsin, Maryland, or North Carolina. (The Maryland case involves districts gerrymandered by the Democratic-controlled legislature. Both parties have been offenders, but Republicans control so many more of the state legislatures that drew new maps after the 2010 Census, that most of the current cases involve GOP-drawn districts.) The justices could ratify the newfound concern among federal judges about partisan gerrymandering, but they could also throw the brakes on the trend by rejecting the new arguments and numerical-approaches. There are signs that both the metric-makers and judges in lower courts are tailoring their decisions and language to appeal to Chief Justice John Roberts or to Justice Anthony Kennedy, possible deciding votes.

Pennsylvania’s case, rooted in the state constitution, is necessarily more limited in scope, but Joshua Douglas, a law professor at the University of Kentucky, noted on Twitter that many state constitutions are more explicit in their guarantees of a right to vote than the U.S. constitutions, offering an alternative or parallel track for plaintiffs seeking to have maps thrown out.

The Pennsylvania decision may be the only one to directly affect the 2018 elections and boost Democrats, but the growing judicial willingness to strike down maps deemed excessively partisan will remain important well after November. Most of the ongoing cases should be decided long before 2020, and the results will likely spawn further litigation. The victors in 2020, especially in state legislatures, will have the once-in-a-decade power to redraw maps following that year’s Census. In recent cycles, that’s produced a partisan feeding frenzy; Democrats, caught off-guard in 2010, have launched a high-profile effort to fight back in 2020. If the recent trend holds, however, judges will be looking over the shoulders of whoever wins in two years, and they will be less willing to tolerate partisan gamesmanship.