RALEIGH, N.C. — Federal judges ruled Tuesday that North Carolina’s congressional district map drawn by legislative Republicans is illegally gerrymandered due to excessive partisanship that gave GOP a rock-solid advantage for most seats and must quickly be redone.

The ruling marks the second time this decade that the GOP’s congressional boundaries in North Carolina have been thrown out by a three-judge panel. In 2016, another panel tossed out two majority black congressional districts initially drawn in 2011, saying there was no justification for using race as the predominant factor in forming them. The redrawn map was the basis for a new round of lawsuits.

The latest lawsuit — filed by election advocacy groups and Democrats — said the replacement to the racial gerrymander also were unlawful partisan gerrymanders. Those who sued argued that Republican legislators went too far when they followed criteria designed to retain the party’s 10-3 majority.

The ruling marks the second time this decade that the GOP’s congressional boundaries in North Carolina have been thrown out by a three-judge panel.

At the time of debate, according to the order, House redistricting chief Rep. David Lewis attempted to justify the criteria by saying during debate that “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.”

“We find that the General Assembly drew and enacted the 2016 plan with intent to subordinate the interests of non-Republican voters and entrench Republican control of North Carolina’s congressional delegation,” U.S. Circuit Court Judge Jim Wynn wrote in the majority opinion. Wynn added that the evidence shows the “plan achieved the General Assembly’s discriminatory partisan objective.”

In their ruling Tuesday, the judges ordered the General Assembly to approve another set of districts by Jan. 24. Candidate filing for the November congressional elections begin Feb. 12. A majority of the judges also agreed they would also hire a redistricting expert to draw replacement boundaries if the legislature won’t.

Through a spokeswoman, one of the legislative defendants, Sen. Ralph Hise of Mitchell County, said lawmakers plan to appeal.

There’s a good chance Republicans will try to ask the U.S. Supreme Court to block the ruling’s enforcement until the justices rule in a similar case they heard from Wisconsin in the fall. But that case involves legislative districts, not a congressional plan.