A 6-3 decision from the Supreme Court on Tuesday rejected a bid to give state legislatures sweeping authority in drawing congressional maps and regulating federal elections, declining to endorse the so-called “independent state legislature” theory.

The majority opinion, which united the court’s three liberals with Chief Justice John Roberts and two conservative justices, preserves the ability for state courts to hear partisan gerrymandering lawsuits in congressional redistricting and review other federal election rules set by state legislatures.

It hands a defeat to North Carolina Republican lawmakers, who advanced the theory as they appealed a lawsuit involving the state’s congressional map.

The lawmakers had argued the federal Constitution vests the authority for regulating federal elections exclusively in state legislatures, meaning the North Carolina Supreme Court and state constitution had no power to block the Legislature’s approved congressional map.

“The Elections Clause does not insulate state legislatures from the ordinary exercise of state judicial review,” Roberts wrote for the majority.

Roberts’s opinion was joined by all three of the court’s liberals — Justices Sonia Sotomayor, Elena Kagan and Ketanji Brown Jackson — and conservative Justices Brett Kavanaugh and Amy Coney Barrett.

The Biden administration had warned adopting that theory would “wreak havoc in the administration of elections across the nation.”

The majority ruled that although state courts retain the ability to review legislatures’ actions, they still must do so in the “ordinary bounds” of judicial review and still have limits when their decisions conflict with federal law.

“Although we conclude that the Elections Clause does not exempt state legislatures from the ordinary constraints imposed by state law, state courts do not have free rein,” Roberts wrote.

For months, however, it remained unclear if the court would actually weigh in on the merits of the case.

Republicans retook control of North Carolina’s top court in the midterm elections and overruled the underlying decision, known as “Harper I.” The high court was effectively hearing an appeal of a ruling that no longer existed.

“The record shows that Harper I finally decided the Elections Clause question, the judgment in that case continues to bind the parties before us, and the 2021 congressional maps would again take effect in North Carolina were we to reverse. Accordingly, we have jurisdiction,” Roberts wrote.

Another SCOTUS decision Tuesday: Colorado man’s stalking conviction vacated in ‘true threat’ First Amendment decision

In his dissent, conservative Justice Clarence Thomas said the court should have tossed the case as a result and that the majority opinion is “plainly advisory.” His dissent was joined by Justice Neil Gorsuch and in part by Justice Samuel Alito.

“This is a straightforward case of mootness,” Thomas wrote. “The federal defense no longer makes any difference to this case—whether we agree with the defense, disagree with it, or say nothing at all, the final judgment in this litigation will be exactly the same.”

In the portion of the opinion joined only by Gorsuch, Thomas went on to disagree with the majority’s argument on the merits.

“In most cases, it seems likely that ‘the bounds of ordinary judicial review’ will be a forgiving standard in practice, and this federalization of state constitutions will serve mainly to swell federal-court dockets with state constitutional questions to be quickly resolved with generic statements of deference to the state courts,” Thomas wrote.

On two occasions after oral arguments in the case, the justices had asked the parties to submit in writing their views about how to proceed, given the jurisdictional issues.

N.C. Republican lawmakers had urged the Supreme Court to still reach a ruling on the merits of the theory. They were joined by one opposing group, which urged the justices to weigh in soon rather than let it hang as an open question in the lead-up to the 2024 presidential election.

The Biden administration and three other groups opposing the independent state legislature theory, on the other hand, told the court that the case was moot.

“The independent state legislature theory is a dangerous, fringe legal theory that has no place in our democracy,” Abha Khanna, a partner at progressive elections firm Elias Law Group, which represented one group of plaintiffs, said in a statement.

“In its most extreme form, the Independent State Legislature Theory could have weakened the foundation of our democracy, removing a crucial check on state legislatures and making it easier for rogue legislators to enact policies that suppress voters and subvert elections without adequate oversight from state court. We are incredibly relieved that the Supreme Court decisively rejected this dangerous theory.”

Vice President Harris, who leads the administration’s voting rights efforts, championed the opinion while continuing to call on Congress to pass bills that support the push.

“Today’s decision preserves state courts’ critical role in safeguarding elections and protecting the voice and the will of the American people. We know that more work must to be done to protect the fundamental right to vote and to draw fair maps that reflect the diversity of our communities and our nation,” Harris said in a statement.

“The President and I will keep fighting to secure access to the ballot box, but we cannot do this alone,” she said.

Updated at 5:33 a.m. EDT.