In a 6-3 decision, the justices said that tax subsidies that make health insurance affordable for low-income individuals are constitutional.
The ruling preserves the law known as Obamacare, which Mr Obama considers a major part of his presidential legacy.
Republicans have vowed to continue fighting the law.
“We’ve got more work to do, but what we’re not going to do is unravel what has now been woven into the fabric of America,” Mr Obama said.
The high court case was the second major challenge to the healthcare law – often known as Obamacare – since its passage.
“Congress passed the Affordable Care act to improve health insurance markets, not to destroy them,” Chief Justice John Roberts wrote in the opinion.
If the law had been overturned, 6.4 million Americans would have been at risk of losing aid.
Opponents argue that a phrase included in the law, “established by the state,” demonstrated that the healthcare subsidies should have only been available for people in states that set up exchanges.
However, most Americans receiving subsidies purchase healthcare through the federal exchange after many states decided not to set up their own marketplaces.
The Obama administration argued that was a too-narrow reading of the law, which spans nearly 1,000 pages, and the rest of the legislation makes clear subsidies are intended for those who meet income requirements, regardless of which exchange insurance was purchased from.
Justice Roberts voted with liberal colleagues in support of the law. He was also the key vote to uphold it in a 2012 case. Justice Anthony Kennedy dissented in 2012, but sided with the majority on Thursday.
Justice Anthony Scalia wrote in his dissent that the Supreme Court is setting a precedent of favouring some laws over others.
“We should start calling this law SCOTUS care” Justice Scalia’s wrote. “Today’s interpretation is not merely unnatural; it is unheard of.”
The upholding of the law cements President Obama’s biggest legislative victory.
Republican Congressional leader Steve Scalise said he was disappointed with the ruling and would work to have the law “repealed and replaced,” echoing near-universal Republican sentiment.
“It does not change the fact that Obamacare has been a dismal failure for millions of Americans who have lost the good healthcare that they liked, and are paying more for the plans that they have,” Mr Scalise said in statement.
Outside the Supreme Court on Thursday, people were celebratory and joyful, chanting “ACA is here to stay!” and “If you’re covered and you know it clap your hands.”
“Today is a good day for healthcare in America,” said demonstrator Benton Strong. “I hope this is the end of the line.”