Extreme partisan gerrymanders can violate North Carolina’s constitution, a state court found Tuesday, in a decision striking down the state legislative maps the GOP statehouse adopted in 2017.

The ruling is a major victory for redistricting reformers after the setback the Supreme Court dealt them in June. North Carolina has been embroiled in lawsuits over its redistricting schemes since the last census, as Republicans have held a majority in the legislature — and until recently, had a supermajority — even as Democrats were able to win statewide offices.

A united three judge-panel said that the current state House and Senate maps — which were adopted by the legislature after its previous maps were found to be illegal racial gerrymanders — violated the state constitution’s Free Elections Clause, the Equal Protection Clause, and Free Speech and Free Assembly Clauses.

“Using their control of the General Assembly, Legislative Defendants manipulated district boundaries, to the greatest extent possible, to control the outcomes of individual races so as to best ensure their continued control of the legislature,” the court said.

The court is giving the legislature until Sept. 18 to draw interim maps for the 2020 elections. While the plan should not interfere with the primary elections next spring, the court also said it was reserving the right to move those primary dates if need be.

The case included the files found on the back-up hard drives of the now-deceased GOP gerrymandering guru Thomas Hofeller, who was tasked by the Republicans with designing the 2017 maps. His estranged daughter discovered the files after his death and offered them to a voting rights group, which subpoenaed them for the case.

As the legislature passed the Hofeller-drawn districts in 2017, Republicans bragged about the partisan advantage the replacement map would give them.

The files, the court said Tuesday, provided evidence of Hofeller’s “predominant focus on maximizing Republican partisan advantage in creating the 2017 Plans.”

“The evidence establishes that Dr. Hofeller drew the 2017 Plans very precisely to create as many ‘safe’ Republican districts as possible, so that Republicans would maintain their supermajorities, or at least majorities even in a strong election year for Democrats” the court said, adding it was “persuaded that Dr. Hofeller drew the maps with an intent to preserve Republicans’ control of the House and Senate.”

The GOP legislators defending the maps in the case offered “no plausible alternative explanation of Dr. Hofeller’s intent as he drew” the districts, the court said.

The thorough, 357-page opinion analyzed expert testimony about how several counties in the state were broken up.

It also repeatedly cited the Supreme Court’s recent partisan gerrymandering opinion and dissent. A 5-4 Supreme Court majority said in that case — which included the North Carolina map the state court reviewed — that federal courts could not review maps for extreme partisan gerrymanders. But the conservative majority also said that states “are actively addressing the issue on a number of fronts” and that “state statutes and state constitutions can provide standards and guidance for state courts to apply.”

The state court concluded that the North Carolina’s constitution gave state courts the authority to review maps for partisan gerrymandering.

“If unconstitutional partisan gerrymandering is not checked and balanced by judicial oversight, legislators elected under one partisan gerrymander will enact new gerrymanders after each decennial census, entrenching themselves in power anew decade after decade,” the state court said.

North Carolina’s Senate Leader Phil Berger (R) said in a statement that the legislature will not appeal Tuesday’s decision.

Read the state court ruling below: