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.