A panel of three judges in North Carolina threw out the state’s legislative district maps on Tuesday, ruling that the maps were such an extreme partisan gerrymander that they violated the state constitution.

Lawmakers' partisan intent in drawing the maps, the "surgical precision" with which they were executed, and the distinct advantage the maps gave to Republicans violated the state’s constitutional protections of free elections, free speech and assembly, and equal protection under the law, the judges wrote in a 357-page ruling that reads as a stinging condemnation of partisan gerrymandering.

"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 judges wrote. "It is not the free will of the People that is ascertained through extreme partisan gerrymandering. Rather, it is the carefully crafted will of the map drawer that predominates."

The ruling is a huge win for voting rights advocates, who say that gerrymandering — the process of drawing district maps to favor a party or politician — undermines democracy by allowing lawmakers to pick the voters. While racial gerrymandering is illegal, the Supreme Court declined to weigh in on partisan gerrymandering earlier this summer.

Partisan gerrymandering in North Carolina presented “political questions beyond the reach of the federal courts," the Supreme Court said in June, leaving advocates to focus their fight on gerrymandering in state courts. The suit was filed by Common Cause, a watchdog group, which heralded Tuesday's ruling as part of a "growing list of victories in the fight to end gerrymandering nationwide" in a statement.

The legislature must immediately start drawing new maps, the court said, demanding that they be drawn based on criteria like population, contiguity, and county lines. They must be drawn without "partisan considerations and election results data," the judges wrote, and done so in plain view, a pointed departure from the closed-door processes the ruling eschews.

"At a minimum, that would require all map drawing to occur at public hearings, with any relevant computer screen visible to legislators and public observers," the ruling said.

New maps must be completed in two weeks, the judges said. The court also said it reserved the right to move the 2020 primary election if needed.

The ruling could have far-reaching effects. It both demands fairer maps and also has the potential to change who is charged with drawing North Carolina’s next set of redistricting maps because lawmakers will redraw the maps after the 2020 Census.

"Control of the North Carolina legislature is much more a jump ball under new maps,” Michael Li, senior counsel at the Brennan Center for Justice at New York University, told NBC News. "The new legislature that’s elected in 2020 will draw the maps in 2021."

Stanton Jones, an attorney for Common Cause, said Tuesday’s ruling could affect the state’s Congressional districts, too.

North Carolina — a purple state — is currently represented by 9 Republicans and three Democrats in Congress, thanks to careful, Republican-drawn districts that advocates say are heavily gerrymandered.

"Today’s decision does not directly address the congressional district, however this decision interprets and applies the North Carolina constitution to prohibit partisan gerrymandering and that ruling should apply equally in the constitution to state legislative district sand congressional districting plans," Jones told reporters.

North Carolina’s maps are among some of the most gerrymandered in the nation, something that was highlighted by the 2018 election, the ruling said. In the 2018 House and Senate elections, Republican candidates won a minority of the two-party statewide vote, but still won majority of state House and Senate seats.

Lawmakers have been gerrymandering for centuries in the U.S., but sophisticated data, computer modeling, and hyper partisanship has made gerrymandered maps more effective over the years, making the maps more powerful and their effect on democracy more profound.