WASHINGTON (AP) -- The Supreme Court on Thursday upheld the nationwide tax subsidies underpinning President Barack Obama's health care overhaul, rejecting a major challenge to the landmark law in a ruling that preserves health insurance for millions of Americans.

The justices said in a 6-3 ruling that the subsidies that 8.7 million people currently receive to make insurance affordable do not depend on where they live, as opponents contended.

The outcome was the second major victory for Obama in politically charged Supreme Court tests of his most significant domestic achievement. And it came the same day the court gave him an unexpected victory by preserving a key tool the administration uses to fight housing bias.

Chief Justice John Roberts again voted with his liberal colleagues in support of the health care law. Roberts also was the key vote to uphold it in 2012. Justice Anthony Kennedy, a dissenter in 2012, was part of the majority on Thursday.

"Congress passed the Affordable Care Act to improve health insurance markets, not to destroy them," Roberts declared in the majority opinion.

Limiting the subsidies only to individuals in states with their own exchanges could well push insurance markets in the other states "into a death spiral," Roberts wrote.

Justice Antonin Scalia, in a dissent he summarized from the bench, strongly disagreed. "We should start calling this law SCOTUScare," he said, using an acronym for the Supreme Court and suggesting his colleagues' ownership by virtue of their twice stepping in to save the law from what he considered worthy challenges.

His comment drew a smile from Roberts, his seatmate and the object of Scala's ire.

Scalia said that Roberts' 2012 decision that upheld the law and his opinion on Thursday "will publish forever the discouraging truth that the Supreme Court of the United States favors some laws over others, and is prepared to do whatever it takes to uphold and assist its favorites."

Justices Samuel Alito and Clarence Thomas joined the dissent, as they did in 2012.

Nationally, 10.2 million people have signed up for health insurance under the Obama health overhaul. That includes the 8.7 million people who are receiving an average subsidy of $272 a month to help pay their insurance premiums.

Of those receiving subsidies, 6.4 million were at risk of losing that aid because they live in states that did not set up their own health insurance exchanges.