North Carolina’s state court delivered Democrats a big win Tuesday, ruling the state’s legislative district map unconstitutional, and paving a path to undo years of Republican gerrymandering in a traditionally competitive state.

In a 357-page decision, a three-judge panel ruled the state’s legislative districts violated the North Carolina State Constitution through “extreme partisan gerrymandering.” The case was brought by Common Cause North Carolina, a nonpartisan group working to end gerrymandering in the state.

“The 2017 Enacted Maps, as drawn, do not permit voters to freely choose their representative, but rather representatives are choosing voters based upon sophisticated partisan sorting,” the ruling states.

The court is leaving it up to the Republican state legislature to redraw the maps, but it is setting specific guidelines for them to follow: The new maps must be redrawn by September 18 (within two weeks), lawmakers can’t use data to try to draw a partisan advantage, and the redrawing process must be public. The court will also appoint a referee to review the redrawn maps before they are enacted, and if the legislature tries to delay, the referee could redraw the maps itself.

“We’re thrilled,” Daniel Jacobson, one of the lead attorneys for the plaintiffs, tells Vox. “They can’t try to delay, which has been one of their main tactics.”

The fact that this is a state court ruling, based on the state constitution, is crucial. In June, the US Supreme Court ruled that federal courts can’t strike down maps on grounds of partisan gerrymandering, but state courts still have the ability to do so. The state’s Republican state leadership has said they will not appeal the decision, guaranteeing new maps in the state, according to a statement from state Senate leader Phil Berger.

This case could be a blueprint for other states — like Wisconsin, Maryland, and Texas — that have extremely gerrymandered maps. It gives Democrats in North Carolina a bigger chance to win back at least one chamber of the state legislature. North Carolina’s governor Roy Cooper, a Democrat, is also up for reelection in 2020.

It “suggests even though the federal courts have stepped away from partisan gerrymandering, there may be remedies in state courts, and people should look at their state constitutions,” says Michael Li, senior counsel for the Brennan Center for Justice at the NYU School of Law. “They didn’t bring it under the US Constitution, they brought it solely under state provisions, that will be what insulates it.”

North Carolina’s gerrymandered maps, explained

North Carolina has a long history of gerrymandering, and both parties have played a part. But the current maps were drawn by Republican lawmakers in 2016, after a US Supreme Court case deemed older maps drawn in 2011 to be an unconstitutional racial gerrymander that disadvantaged the state’s black voters.

North Carolina’s Republican-leaning gerrymandering was apparent in recent election results. In the 2018 elections, state Republicans received less than half the vote overall, yet they still control 29 out of 50 state Senate seats and 65 out of 120 state House seats.

That is “just is not something in a 50/50 state that occurs naturally,” Li told Vox. “And it didn’t.”

When it came time to redraw the maps in 2016, Republicans made clear they were doing it to consolidate political power. Republican state Rep. Dave Lewis publicly admitted as much during the 2016 process.

“I propose that we draw the maps to give a partisan advantage to 10 Republicans and three Democrats, because I do not believe it’s possible to draw a map with 11 Republicans and two Democrats,” Lewis said at a state House hearing.

Recently discovered files showed that GOP strategist Tom Hofeller, who died in 2018, drew the maps in North Carolina Republican Party’s headquarters specifically using prior election results to “construct the district boundaries to advantage Republicans,” the court ruling outlines.

Gerrymandering has bolstered Republicans’ grip on power

When Democrats managed to elect Roy Cooper to the governor’s mansion in 2016 — one of the few bright spots for Democrats in a year that was dominated by Donald Trump and Republican victories — their wins were spoiled by the Republican state legislature.

Within 48 hours of Cooper’s victory, the Republican-controlled state legislature passed a series of bills that pulled Cooper’s ability to make key cabinet appointments without their approval, drastically cut the size of Cooper’s administration, and changed the Board of Elections so that Republicans would control it in election years. They ensured lawsuits had to first go through the Republican-controlled appeals court, before the Democratic-majority state Supreme Court.

Cooper, and state Democrats, have been fighting these changes since. They’ve been successful on some fronts; for instance, the state Board of Elections move was ruled unconstitutional. But Cooper’s administration has been reduced to trying to energize the people of North Carolina to fight an explicit Republican power grab, while trying to battle the GOP-controlled legislature in the courts as well.

In 2018, other states, like Michigan and Wisconsin, also elected new Democratic governors — who came in to face Republican legislative majorities that have been entrenched through gerrymandering.

Since those gerrymandered state legislatures draw their own district lines, it can seem enormously challenging to ever dislodge them. But this case shows that the state courts can still step in and provide a way out.