Washington — In a major victory for President Obama and his health-care reform law, the US Supreme Court on Thursday agreed with the law’s supporters that the statute authorizes billions of dollars in tax credits through health-care exchanges, regardless of whether they were set up by a state or the federal government.

In a 6-to-3 decision, the high court acknowledged that the counterarguments in the case were “strong,” but that a “fair reading of the legislation demands a fair understanding of the legislative plan.”

“Congress passed the Affordable Care Act to improve health insurance markets, not to destroy them,” Chief Justice John Roberts wrote in the majority opinion.

In reaching that conclusion, the justices embraced a broad reading of a key provision of the ACA that critics said restricted the awarding of tax subsidies to only those consumers who buy their policies on a health care exchange established by a state, rather than one set up by the federal government.

Only 16 of the 50 states established their own state health exchanges. In the other 34 states, the federal government moved to fill the void by setting up federal exchanges.

The decision means that tax credits will continue to be available through federal exchanges. That, in turn, means that 7 to 8 million Americans who rely on those credits will likely continue to be able to afford their health-care policies with the help of government subsidies.

Analysts had warned that without tax subsidies millions would lose their health insurance and many of the federally-established exchanges might plunge into economic death spirals.

“Reliance on context and structure in statutory interpretation is a subtle business,” the chief justice said in a 21-page decision. “Such reliance is appropriate in this case, and leads us to conclude that [the law] allows tax credits for insurance purchased on any exchange created under the act.”

He added that the credits were necessary “to avoid the type of calamitous result that Congress plainly meant to avoid.”

In a dissent, Justice Antonin Scalia noted that the Supreme Court in 2012 had upheld the ACA from a constitutional challenge in part by re-interpreting it as a tax measure. He said that in Thursday’s decision the court had again transformed the law in a significant way to prevent its demise.

“We should start calling this law SCOTUScare,” he said, given the court’s helpful redrafting of key provisions of Obamacare. (SCOTUS is the shorthand used by many lawyers to refer to the Supreme Court of the United States.)

Justice Scalia criticized the court for rewriting the ACA rather than applying the statute’s text as written by Congress.

“Today’s interpretation is not merely unnatural; it is unheard of,” Scalia wrote. “Who would ever have dreamt that ‘Exchange established by the state’ means ‘Exchange established by the state or the federal government?’ “

“Rather than rewriting the law under the pretense of interpreting it, the court should have left it to Congress to decide what to do about the act’s limitation of tax credits to state exchanges,” he said.

At issue in the case was whether the ACA authorized the Internal Revenue Service to enact a 2012 rule that distributed billions of dollars in tax credits through health-care exchanges set up by the federal government.

A group of Obamacare opponents in Virginia challenged the regulation. They argued that the text of the ACA requires that tax credits shall only be distributed through a health-care exchange “established by the state.”

The Obama administration urged the court to adopt a broader reading of the ACA, arguing that subsidies were permitted in both state-established and federally-established exchanges. It didn’t matter who set up the exchange, the administration said, what mattered was that it was up and running in a particular state.

In embracing the administration’s broad reading of the ACA, the majority justices determined that the rule passed by the IRS authorizing distribution of tax credits via federal exchanges was unnecessary.

The regulation was enacted by the Obama administration to make clear that tax credits could be distributed through both state and federal exchanges. Such issues are usually resolved by requesting a legislative fix from Congress. But by 2012, when the question arose, Republicans had taken control of the House of Representatives and appeared intent on overturning the law rather than fixing it.

That’s when the administration sought to use the regulatory process to answer the question.

“The tax credits are among the act’s key reforms, involving billions of dollars in spending each year and affecting the price of health insurance for millions of people,” Roberts wrote.

“Whether those credits are available on federal exchanges is thus a question of deep economic and political significance that is central to this statutory scheme,” Roberts said. “Had Congress wished to assign that question to an agency, it surely would have done so expressly.

“It is especially unlikely that Congress would have delegated this decision to the IRS, which has no expertise in crafting health insurance policy of this sort,” he said. “This is not a case for the IRS.”

In rejecting the IRS regulatory avenue, the court said under a “fair construction of the statute” it seemed that Congress itself meant for tax credits to apply in all exchanges nationwide. The court acknowledged that the ACA contained “more than a few examples of inartful drafting.”

But the majority justices concluded that was no reason to embrace an interpretation that would likely undercut the law’s broader design.

“We must do our best, bearing in mind the fundamental canon of statutory construction that the words of a statute must be read in their context and with a view to their place in the overall statutory scheme,” Roberts wrote.

“Here, the statutory scheme compels us to reject petitioners’ interpretation because it would destabilize the individual insurance market in any state with a federal exchange, and likely create the very ‘death spirals’ that Congress designed the act to avoid,” he said.

Scalia said the Supreme Court enjoys no “free-floating power to rescue Congress from its drafting errors.”

“It is entirely plausible that tax credits were restricted to state exchanges deliberately – for example, in order to encourage states to establish their own exchanges,” he said.

“We therefore have no authority to dismiss the terms of the law as a drafting fumble,” he wrote.

Scalia noted that Congress included the term “established by the state” seven times in the statute. “What are the odds, do you think, that the same slip of the pen occurred in seven separate places?”

He said the majority opinion reflects “the philosophy that judges should endure whatever interpretive distortions it takes in order to correct a supposed flaw in the statutory machinery.”

Scalia said Congress, not the court, is responsible for both making laws and mending them. “This court holds only the judicial power – the power to pronounce the law as Congress has enacted it,” he said. “We lack the prerogative to repair laws that do not work out in practice.”