Read the rest of Slate’s coverage on the Supreme Court upholding the Affordable Care Act.

There were two battles being fought in the Supreme Court over the Affordable Care Act. Chief Justice John Roberts—and Justice Anthony Kennedy—delivered victory to the right in the one that mattered.

Yes, Roberts voted to uphold the individual mandate, joining the court’s liberal wing to give President Obama a 5-4 victory on his signature piece of legislation. Right-wing partisans are crying treason; left-wing partisans saw their predictions of a bitter, party-line defeat undone.

But the health care law was, ultimately, a pretext. This was a test case for the long-standing—but previously fringe—campaign to rewrite Congress’ regulatory powers under the Commerce Clause.

This is why the challenge to the ACA, and its progress through the courts, came as a surprise to Democrats and to mainstream constitutional scholars: Three years ago, there was no serious doubt that Congress had the power to impose the individual mandate.

A Bloomberg story last week nicely captured the stakes: “Obama Health Law Seen Valid, Scholars Expect Rejection“:

The U.S. Supreme Court should uphold a law requiring most Americans to have health insurance if the justices follow legal precedent, according to 19 of 21 constitutional law professors who ventured an opinion on the most-anticipated ruling in years.

Only eight of them predicted the court would do so.

The scholars expected to see the court gut existing Commerce Clause precedent and overturn the individual mandate in a partisan decision: Five Republican-appointed justices voting to rewrite doctrine and reject Obamacare; four Democratic-appointed justices dissenting.

Roberts was smarter than that. By ruling that the individual mandate was permissible as a tax, he joined the Democratic appointees to uphold the law—while joining the Republican wing to gut the Commerce Clause (and push back against the necessary-and-proper clause as well). Here’s the Chief Justice’s opinion (italics in original):

Construing the Commerce Clause to permit Congress to regulate individuals precisely because they are doing nothing would open a new and potentially vast domain to congressional authority. Congress already possesses expansive power to regulate what people do. Upholding the Affordable Care Act under the Commerce Clause would give Congress the same license to regulate what people do not do. The Framers knew the difference between doing something and doing nothing. They gave Congress the power to regulate commerce, not to compel it. Ignoring that distinction would undermine the principle that the Federal Government is a government of limited and enumerated powers. The individual mandate thus cannot be sustained under Congress’s power to “regulate Commerce.”

The business about “new and potentially vast” authority is a fig leaf. This is a substantial rollback of Congress’ regulatory powers, and the chief justice knows it. It is what Roberts has been pursuing ever since he signed up with the Federalist Society. In 2005, Sen. Barack Obama spoke in opposition to Roberts’ nomination, saying he did not trust his political philosophy on tough questions such as “whether the Commerce Clause empowers Congress to speak on those issues of broad national concern that may be only tangentially related to what is easily defined as interstate commerce.” Today, Roberts did what Obama predicted he would do.

Roberts’ genius was in pushing this health care decision through without attaching it to the coattails of an ugly, narrow partisan victory. Obama wins on policy, this time. And Roberts rewrites Congress’ power to regulate, opening the door for countless future challenges. In the long term, supporters of curtailing the federal government should be glad to have made that trade.