The decision means the huge overhaul, still only partly in effect, will proceed and pick up momentum over the next several years, affecting the way that countless Americans receive and pay for their personal medical care. The ruling also hands Obama a campaign-season victory in rejecting arguments that Congress went too far in requiring most Americans to have health insurance or pay a penalty.
Chief Justice John Roberts announced the court's judgment that allows the law to go forward with its aim of covering more than 30 million uninsured Americans.
The justices rejected two of the administration's three arguments in support of the insurance requirement. But the court said the mandate can be construed as a tax. "Because the Constitution permits such a tax, it is not our role to forbid it, or to pass upon its wisdom or fairness," Roberts said.
The court found problems with the law's expansion of Medicaid, but even there said the expansion could proceed as long as the federal government does not threaten to withhold states' entire Medicaid allotment if they don't take part in the law's extension.
The court's four liberal justices, Stephen Breyer, Ruth Bader Ginsburg, Elena Kagan and Sonia Sotomayor, joined Roberts in the outcome.
Justices Samuel Alito, Anthony Kennedy, Antonin Scalia and Clarence Thomas dissented.
"The act before us here exceeds federal power both in mandating the purchase of health insurance and in denying non-consenting states all Medicaid funding," the dissenters said in a joint statement.