TheU.S. Supreme Court on Thursday blessed extreme partisan gerrymandering, giving politicians a green light to draw electoral districts that keep them in power indefinitely.

In a 5-4 decision, Chief Justice John Roberts wrote that partisan gerrymandering was a political question beyond the reach of the federal court. There are no fair and manageable standards for judges to evaluate whether a gerrymander is constitutional, Roberts wrote in his majority opinion.

“We conclude that partisan gerrymandering claims present political questions beyond the reach of the federal courts,” Roberts wrote in Thursday’s decision. “Federal judges have no license to reallocate political power between the two major political parties, with no plausible grant of authority in the Constitution, and no legal standards to limit and direct their decisions.”

Roberts was joined by the court’s four other conservative justices in the majority.

The court’s decision ensures state lawmakers will have virtually unlimited license to choose the voters who elect them. By packing the opposing party’s voters into as few districts as possible or spreading them out among many districts, lawmakers can make it next to impossible for the other party to win a majority of legislative or congressional seats.

Justice Elena Kagan, in a dissenting opinion joined by the three other liberal-leaning justices, wrote about the corrosive effect gerrymandering has on American democracy. New technology, she said, would only make the practice more extreme.

“If left unchecked, gerrymanders like the ones here may irreparably damage our system of government,” she wrote. “Of all times to abandon the Court’s duty to declare the law, this was not the one. The practices challenged in these cases imperil our system of government. Part of the Court’s role in that system is to defend its foundations. None is more important than free and fair elections.”

Kagan further added, “The majority’s idea instead seems to be that if we have lived with partisan gerrymanders so long, we will survive.”

Gubernatorial and state legislative elections later this year and in 2020 will now determine which party controls redistricting for the following decade. Republicans currently have the power to draw far more congressional districts than Democrats do (179 to 76); if that continues after the 2020 elections, the Supreme Court’s decision will effectively entrench GOP rule.

The cases the Supreme Court ruled on involved congressional districts in North Carolina and Maryland, two great examples of the power of gerrymandering. In North Carolina, Republicans have controlled nearly all of the state’s 13 congressional seats since 2012, even though they’ve consistently won only about half of the statewide congressional vote. In Maryland, Democrats redrew one of the state’s congressional districts in 2011, flipping it from a Republican one to a Democratic one. Roscoe Bartlett, who represented the district, won with over 60% of the votes in 2010. In 2012, with new district lines in place, he lost to a Democrat by more than 20 percentage points. Democrats have held a 7-to-1 edge in that’s state’s congressional delegation ever since.

The Supreme Court’s ruling in the suit, which is actually two consolidated cases ― Rucho v. Common Cause and Lamone v. Benisek ― is a disappointment to gerrymandering reform activists, who argued that Maryland and North Carolina were clear-cut examples of egregious partisan gerrymandering and that the court had to act. Lawmakers in both cases had admitted they drew electoral boundaries with the specific intent of advantaging their own party.

In North Carolina, Republicans had to redraw the state’s congressional districts after a 2016 court ruling said their first attempt had unlawfully diluted the influence of black voters. When they set out to draw a new map later that year, Republicans required that it continue to give Republicans a 10-to-3 advantage and told the mapmaker they hired not to consider race. A top Republican in the legislature boasted that the reason lawmakers were passing a 10-to-3 map was because it was not possible to draw a map that was 11-to-2.

The plaintiffs in the North Carolina case ― Democratic voters in each of the state’s congressional districts, the state Democratic Party and civic groups ― argued that the districts in North Carolina clearly violated the First Amendment’s guarantee of freedom of speech and the 14th Amendment’s guarantee of equal protection of the law. They also said lawmakers were essentially guaranteeing election outcomes, violating provisions of Article I of the Constitution, which says the members of the House of Representatives shall be chosen by “the people” and allows lawmakers to only set the “time, manner and place” of elections.

The Maryland case involved a challenge to the state’s 6th Congressional District. The plaintiffs, Republican voters, said that Democrats intentionally gerrymandered the district in 2011 to flip it from a Republican one to a Democratic one.

During oral arguments in March, the more conservative justices on the court did not seem eager to weigh in on partisan gerrymandering. The U.S. Constitution gives lawmakers the power to draw district lines, and the conservative justices seemed hesitant to embrace the idea that the court had a responsibility to step in and decide when gerrymandering is so egregious that it becomes unconstitutional. They also appeared skeptical that there was a way to figure out when gerrymandering was so severe that it was unconstitutional.

“There are no legal standards discernible in the Constitution for making such judgments, let alone limited and precise standards that are clear, manageable, and politically neutral,” Roberts wrote. “Any judicial decision on what is ‘fair’ in this context would be an ‘unmoored determination’ of the sort characteristic of a political question beyond the competence of the federal courts.”

Paul Clement, a prolific Supreme Court lawyer who served as solicitor general under George W. Bush, argued on behalf of North Carolina lawmakers. He warned the court against striking down the districts, saying it would invite a flood of lawsuits from people who were dissatisfied with the results of elections.

The gerrymandering reform advocates on the other side of the case were concerned that computer mapping, big data and other new technology would allow lawmakers to gerrymander more precisely than they ever had before.

Democrats are determined not to let Republicans have as much influence in redrawing electoral boundaries in 2021 as they did in 2011. Former Attorney General Eric Holder is leading a group, the National Democratic Redistricting Committee, focused on helping Democrats win key state races that will ensure they have a seat at the table during redistricting.

There is also a movement to rein in excessive partisan gerrymandering outside of the courts. Voters in Michigan, Colorado, Utah and Missouri approved ballot initiatives to either allow independent commissions to redistrict or to limit excessive political considerations.

Marina Fang contributed reporting.