President Barack Obama’s key legislation of his administration, the Affordable Care Act, has survived another challenge from the Supreme Court. The court ruled 6-3 in favor of the part of the law that provides federal subsidies to help the poor and middle class afford health insurance.

Chief Justice John Roberts wrote the opinion. The court’s conservative members - Justices Antonin Scalia, Samuel Alito and Clarence Thomas - were the dissenting votes.

As the New York Times notes, the key issue in the case was a phrase in the law that Congress passed that suggested that the subsidies would only be available to people who use online site exchanges that were established by states. However, people who used sites established by the federal government had also qualified for a federal subsidy that made up for states that didn’t create their own exchanges.

The plaintiffs, who were all from Virginia, sued the Obama Administration and challenged the IRS regulation that allowed this. The administration’s lawyers suggested that Congress didn’t intend to limit subsidies, which Roberts agreed with.

“In this instance, the context and structure of the act compel us to depart from what would otherwise be the most natural reading of the pertinent statutory phrase,” Roberts wrote. “Congress passed the Affordable Care Act to improve health insurance markets, not to destroy them. If at all possible, we must interpret the act in a way that is consistent with the former, and avoids the latter.”

CNN reports that if the court had overturned this part of the Obamacare law, it would have affected 6.4 million people who had applied for health care through federal-established exchanges. Only 16 states and Washington DC set up their own marketplaces, with 34 states letting the federal government run their exchanges.

This is the second time that Roberts has saved portions of Obamacare. In 2012, he was the deciding vote to declare that the law’s individual mandate is constitutional.

The full case opinion can be found here.