A panel of federal judges invalidated North Carolina’s congressional map Tuesday, ruling the districts drawn by the state’s Republican legislature constituted illegal gerrymandering in violation of the Constitution’s equal-protection clause. The court ordered the state to redraw the map before congressional midterm elections later this year.

“We agree with plaintiffs that a wealth of evidence proves the General Assembly’s intent to ‘subordinate’ the interests of non-Republican voters and ‘entrench’ Republican domination of the state’s congressional delegation,” Judge James A. Wynn Jr., an Obama appointee, wrote in a 205-page opinion. Wynn went on to say the Republicans’ “plan achieved the General Assembly’s discriminatory partisan objective.” According to the order, at the time when the congressional districts were redrawn, the Republican in charge of the redistricting effort in the statehouse, Rep. David Lewis, justified the map saying: “I think electing Republicans is better than electing Democrats. So I drew this map to help foster what I think is better for the country.”

Tuesday’s rebuke of Republican gerrymandering in North Carolina was extraordinary in that it was the first time a federal court had ever gone so far as to block the implementation of a congressional map writ large, according to the New York Times. It is not, however, the first time a court has taken issue with the party’s efforts to get the upper hand in North Carolina. In 2016, the court rejected two majority black congressional districts drawn in 2011 “saying there was no justification for using race as the predominant factor in forming them,” according to the Associated Press.

The judges set a deadline of Jan. 24 for the state’s General Assembly to propose a new plan for drawing the congressional map. Candidates in North Carolina can begin filing to run for congress on Feb. 12, meaning time is short to overhaul the districts. If the state legislature is unable to come up with a suitable alternative, the court said it would take charge and hire an expert to draw replacement boundaries. The North Carolina Republican Party is expected to appeal the case with an eye on the Supreme Court intervening.