North Carolina is a purple state, narrowly electing a Democratic governor in 2016 while giving a slim presidential victory to Republican Donald Trump. But its congressional delegation is not split so evenly. Republicans hold 10 seats and Democrats only three.

Asked why, one GOP state legislator involved in designing district boundaries had a pithy explanation: “Because I don’t believe it’s possible to draw a map with 11 Republicans and two Democrats.”

North Carolina’s lawmakers made no bones about their intention to divvy up voters so the GOP would retain a large majority of the state’s congressional delegation no matter which way the political winds blow. And they succeeded. But this month, a federal appeals court ruled the redistricting plan unconstitutional because of its discriminatory purpose and effect. It was the first time a federal court had ever struck down a map because of partisan gerrymandering.

Parties in power have practiced this method to entrench themselves for as long as anyone can remember. But modern technology has made it possible for legislators to carry out their mission with nearly infallible results.

The Supreme Court, which regularly polices redistricting to prevent racial discrimination, has always declined to overturn such districts on partisan grounds. But in October, the justices heard a case involving a state legislative map in Wisconsin that was also invalidated for unduly favoring Republicans. They have also agreed to consider a lawsuit filed by Republicans over a Maryland congressional district drawn by the Democratic legislature. The court may take the North Carolina case as well.

The case against partisan gerrymandering is not hard to make. It frustrates democracy by preventing voters from evicting those in power. It penalizes voters of one party or the other by deliberately diluting their electoral strength. It renders the consent of the governed largely moot.

In North Carolina, the court said the congressional map violated the equal protection clause and First Amendment by discriminating against voters who are not Republicans. Wisconsin’s plan was struck down on similar grounds. But in a Pennsylvania case decided this month, a federal appeals court concluded it was not the job of the judiciary to fix such distortions. “The framers provided a check on state power within the text of the elections clause, but it is a political one — action by Congress,” the court said.

But even if voters want a change, the unfair drawing of district lines is likely to keep them from getting their way in Congress. When elected bodies rig the system, only the courts are in a position to create a level playing field.

As the appeals court noted in the North Carolina case, judges merely have to find “(1) discriminatory intent, (2) discriminatory effects, and (3) a lack of justification for the discriminatory effects.” The courts have had a lot of practice applying such tests for alleged racial gerrymandering.

Partisan gerrymandering is an abuse Republicans ought to fear will be deployed against them. In 2018 and 2020, they may lose control of many state legislatures just as the time comes for decennial redistricting.

Given that Republicans now make up 34 of the nation’s governors — elected on a statewide basis, not subject to gerrymandering — they should have few reservations about their ability to prevail in fair elections.

Fair elections, however, are becoming less and less common. It’s up to the Supreme Court to restore the power of the citizenry to govern itself.