In a 5-4 ruling, the justices affirmed the constitutionality of the law's requirement that all Americans have health insurance by 2014 or pay a penalty.
"Today's decision was a victory for people all over this country whose lives will be more secure because of this law," said Obama.
"Our mission is clear, if we want to get rid of Obamacare, we're going to have to replace President Obama. My mission is to make sure we do exactly that," said Republican presidential candidate Mitt Romney.
The justices' ruling means the historic overhaul will continue to take effect over the next several years.
The ruling affects tens of millions of Americans, in particular the poor, uninsured, and young people covered under their parents' plans.
Though opponents had argued the law gave the government too much authority, the high court said Congress can regulate people's actions.
Legal scholars are poring over the nearly 200-page decision.
The vote was 5-4, with conservative Chief Justice John Roberts siding with the more liberal members of the court.
The ruling upheld what was at the heart of the case - the individual mandate, the law's requirement that everyone be insured by 2014 or pay a penalty of thousands of dollars.
The high court said the government can't force people to buy health insurance, but it can strongly encourage them to do so through penalties or taxation.
"It's a choice individuals make. Either they buy the insurance or they pay the tax," said Prof. Michael Zimmer, Loyola University Law School.
"Chief Justice Roberts said taxes on cigarettes, taxes on liquor regulate conduct as well and yet those are clearly within the taxing power ... of Congress," said Prof. Sheldon Nahmod, Chicago Kent College of Law.
Opponents of the law had said it was too broad and intrusive, but in his opinion Chief Justice Roberts said it's not the court's "job to protect the people from the consequences of their political choices."
"They're not making a judgment on whether it is a good or bad law. It is just a question of whether it's constitutional or not. They said it's not unconstitutional," said Zimmer.
By upholding individual mandate, other provisions of the law are allowed to survive. People with pre-existing conditions can't be denied health insurance; those on Medicare have access to free mammograms; Coverage can't be denied because of mistakes made on insurance applications; And those under 26 can be insured under their parents' plans.
Ron Stevens has a college age daughter who nearly lost her battle with depression a few years ago but is now receiving treatment. Had the law been struck down Thursday, Stevens feared his daughter would have struggled to find insurance after college because of her pre-existing condition.
"Whether my daughter would have found a way or not, I don't know," said Stevens. "But for many, many people, thousands of people, it would have been life or death. Lives would have been lost."
Not all portions of the law were upheld. The high court struck down a provision relating to the expansion of Medicaid. The court said states can opt out of covering more people without losing all of its federal Medicaid funding, which had been stated in the law.