Washington (CNN)The Supreme Court said Thursday that federal courts must stay out of disputes over when politicians go too far in drawing district lines for partisan gain -- a dramatic and sweeping ruling that could fundamentally affect the balance of power in state legislatures and Congress.
Chief Justice John Roberts wrote the 5-4 decision for the conservative majority.
"Excessive partisanship in districting leads to results that reasonably seem unjust. But the fact that such gerrymandering is 'incompatible with democratic principles' ... does not mean that the solution lies with the federal judiciary," he wrote.
"We conclude that partisan gerrymandering claims present political questions beyond the reach of the federal courts," Roberts added. "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."
Justice Elena Kagan read a scathing dissent from the bench for the four liberals.
"(G)errymandering is, as so many Justices have emphasized before, anti-democratic in the most profound sense," Kagan wrote.
"Of all times to abandon the Court's duty to declare the law, this was not the one," Kagan said. "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."
Roberts said he believes this ruling does not mean there cannot be limits on partisan gerrymandering.
"Our conclusion does not condone excessive partisan gerrymandering," he wrote. "Nor does our conclusion condemn complaints about districting to echo into a void. The States, for example, are actively addressing the issue on a number of fronts."
The court was asked to consider when politicians go too far in drawing lines for partisan gain in a set of cases arising from North Carolina and Maryland.
The North Carolina case was brought by Democrats challenging Republican-drawn maps, while the Maryland case was brought by Republicans challenging a Democratic map.
This story is breaking and will be updated.