WASHINGTON — Partisan gerrymandering is not an issue that can be dealt with by federal courts, the US Supreme Court ruled in a 5–4 decision Thursday, declining to weigh in on two cases that accused politicians in Maryland and North Carolina of rigging their maps in favor of their respective parties.

In the majority opinion, Chief Justice John Roberts wrote that while “[e]xcessive partisanship in districting leads to results that reasonably seem unjust,” it would be inappropriate for the federal courts to weigh in, writing that that would represent an “unprecedented expansion of judicial power.”

“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 wrote, noting that the court has “never struck down a partisan gerrymander as unconstitutional — despite various requests over the past 45 years.”

Thursday’s decision does not apply to racial gerrymandering, however. Roberts reiterated in his decision that the courts do still have a role in those cases, as well as “one-person, one-vote” cases.

Roberts suggested instead that states and Congress could pass legislation on partisan gerrymandering. And he noted that the courts could continue to weigh in on partisan gerrymandering cases in which there were conflicts with state law, citing a 2015 case in which the Supreme Court struck down maps in Florida. But he noted that there was no similar federal law on the books for the court to consider.

Roberts, ultimately, vacated previous lower court decisions on both cases and sent them back “with instructions to dismiss for lack of jurisdiction.” Roberts was joined by Justices Clarence Thomas, Samuel Alito, Brett Kavanaugh, and Neil Gorsuch.

Supreme Court Justice Elena Kagan dissented, joined by the liberal wing of the court: Justices Ruth Bader Ginsburg, Stephen Breyer, and Sonia Sotomayor. Kagan criticized the majority, writing that “for the first time ever” the court had refused to “remedy a constitutional violation because it thinks the task beyond judicial capabilities.” And it’s a problem that “will only get worse (or depending on your perspective, better),” she argued, “as time goes on — as data becomes ever more fine-grained and data analysis techniques continue to improve.”

“Of all times to abandon the Court’s duty to declare the law, this was not the one,” Kagan concluded. “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. With respect but deep sadness, I dissent.”

The two cases before the court involved allegations that state lawmakers in Maryland and North Carolina engaged in unconstitutional partisan gerrymandering — drawing electoral maps in a way that is unlawfully rooted in political considerations. These cases were separate from previous lawsuits involving claims of illegal race-based gerrymandering, but have proved similarly thorny for the courts to sort out over the years.

Partisan gerrymandering cases have come before the Supreme Court before, and the court has similarly either avoided making a firm decision about the role of the courts in such cases and, if there was a role for judges, what the standard should be.

The North Carolina case began as a fight over whether Republican state lawmakers had engaged in unconstitutional racial gerrymandering, but morphed into a dispute over partisan map-drawing. In that case, Democrats in the state lodged challenges to the redistricting map crafted by Republican lawmakers. A lower court found that the challengers had standing to bring vote-dilution claims with respect to the statewide map, and that the state had engaged in unconstitutional partisan gerrymandering in drawing lines.

Lawyers for the Republican lawmakers argued broadly that courts should not be in the business of deciding when it’s acceptable for politics to be a factor in redistricting, and to what extent. Drawing electoral maps is an inherently political process, they argued, and it undermined the independence of the judiciary to get involved.

After a panel of judges struck down North Carolina’s redistricting map in 2016 for racial gerrymandering, state lawmakers came up with a new version based on political data, with the goal of preserving the number of Republicans and Democrats representing the state in Congress, according to court filings. (North Carolina currently has eight Republicans in Congress, three Democrats, and two open seats.)

The North Carolina map was the product of efforts by the late Republican strategist Thomas Hofeller, whose involvement in redistricting recently came up in litigation over whether the Trump administration could add a citizenship question to the 2020 census. According to court briefs, after the earlier version of the map was rejected for racial gerrymandering, lawmakers asked Hofeller to draw a new, politically focused version. The state then appointed a committee to approve a final map.

In the North Carolina cases, there were three main issues before the court. First, whether the challengers — voting rights organizations — had standing to sue. Second, if they did have standing, whether the court should be involved in deciding such cases at all. Finally, if the courts could intervene, what was the standard for determining if a map involved unconstitutional partisan gerrymandering, and did the North Carolina map pass legal muster.

In the Maryland case, Republican voters challenged the state’s congressional redistricting plans after the 2010 census. Unlike the statewide challenge filed in North Carolina, however, the Maryland case was about the lines drawn for a single district, the 6th District. The voters alleged that state lawmakers had redrawn the map to dilute their power in what had previously been a “solid Republican” district, violating their First Amendment speech and political association rights. A lower court sided with the Republicans.

Maryland Democrats argued that their case was different from the North Carolina litigation because the political imbalance in Maryland was far greater — Democrats have controlled the statehouse since 1920, according to their court papers — which meant that their map reflected the fact that Democrats represented a solid majority in the state. Unlike Republicans in North Carolina defending their map, Democrats in Maryland advocated for the justices to adopt a standard for what amounts to unconstitutional partisan gerrymandering, but argued their map was lawful.

This is a developing story. Check back for updates and follow BuzzFeed News on Twitter.‏