In this photo, Former Gov. Arnold Schwarzenegger speaks outside of the United States Supreme Court after oral arguments in Gill v. Whitford to call for an end to partisan gerrymandering in Washington D.C., Oct. 3, 2017. Getty Images

A federal court in North Carolina ruled Tuesday that the state will have to quickly redraw its 13 congressional districts because the map was unconstitutionally partisan and was favoring Republican candidates ahead of midterm elections in 2018.

The ruling by the District Court for the Middle District of North Carolina consisting of a three-judge panel rejected the previous map drawn by the Republican-controlled General Assembly in 2016 after a 2011 electoral map was determined to constitute racial gerrymandering, saying the map violates the Equal Protection Clause, the First Amendment, and Article I of the Constitution.

The judges gave the state about three weeks to file a new plan with the court so that it would be in place before the 2018 midterms. Candidate filing is supposed to begin from Feb. 12.

Ralph Hise, North Carolina's state Senate redistricting chairman, told Reuters via a spokeswoman that Republicans would appeal.

Judge James A. Wynn of the 4th U.S. Circuit Court of Appeals wrote the majority opinion. "...Partisan gerrymandering runs contrary to numerous fundamental democratic principles and individual rights," he wrote.

The 191-page ruling found that the map violated the Constitution on all three counts put forward by plaintiffs and it also ordered that no more elections be conducted using the 2016 plan, asserting that the 2018 general election "remains many months away" and there was thus no pressing need to use the current map.

Gerrymandering refers to the practice of drawing voting districts in order to benefit one party over another in elections. For example, someone drawing political district lines might cluster opposition party voters together in one district in order to concentrate their votes so that they influence only a few seats. Or it could also mean grouping those opposition voters into such districts where the other party has a lock on power — making it very difficult for the opposing party to win elections there, thus giving one party a lopsided advantage over the other in an election.

The term was first developed in Massachusetts in 1812 by a Boston newspaper. It was in response to then Governor Elbridge Gerry’s redrawing of a Massachusetts district that was designed to elect Democratic-Republicans over Federalists. The district was said to have resembled a salamander, and the term gerrymander came from putting the two words together. An editorial cartoon in a Boston newspaper depicting the district as a monster helped in popularizing the term.

Questions have been raised whether gerrymandering is legal. There is currently no law against the process, however the outcome of the Wisconsin gerrymandering case could alter that. If the Supreme Court sides with the challengers rather than supporting the Wisconsin government that created the district map, then some forms of partisan gerrymandering could be ruled unconstitutional.

The Tuesday ruling came as the Supreme Court was already considering two other cases that could reshape how voting districts are drawn in the country. The Supreme Court had ruled against racial gerrymandering earlier, however it has never before ruled on whether partisan gerrymandering is to be considered unconstitutional.

The court had first heard oral arguments in October 2017 for the Gil v. Whitford, a case which challenged the constitutionality of a 2011 redistricting of the state of Wisconsin. That map by Wisconsin’s Republican lawmakers resulted in the party gaining a super majority- 60 of State Assembly’s 99 seats, despite Republican candidates winning just 48.6 percent of Wisconsin votes statewide. After Democratic voters argued that this outcome clearly demonstrated an efficiency gap, the Supreme Court sided with them, ruling that the map unconstitutionally slanted the election in favor of the Republicans.

However, Wisconsin officials appealed the ruling. Although a lower court ordered Wisconsin to redraw a new plan by the fall, the Supreme Court has put a hold to that order.

The Supreme Court also added a second gerrymandering case to its docket in December. The case, Benisek v. Lamone, was brought by Republican voters who said that Democratic state lawmakers had redrawn a Maryland congressional district to retaliate against citizens, who supported its longtime incumbent, Representative Roscoe G. Bartlett, a Republican. The plaintiffs said this retaliation violated the First Amendment by diluting their voting rights.