WASHINGTON — The Supreme Court on Thursday left standing the basic provisions of the health care overhaul, ruling that the government may use its taxation powers to push people to buy health insurance.


The narrowly delineated decision was a victory for President Obama and Congressional Democrats, with a 5-to-4 majority, including the conservative chief justice, John G. Roberts Jr., affirming the central legislative pillar of Mr. Obama's presidency.


Chief Justice Roberts, the author of the majority opinion, surprised observers by joining the court's four more liberal members in the key finding and becoming the swing vote. Justice Anthony M. Kennedy, frequently the swing vote, joined three more conservative members in a dissent and read a statement in court that the minority viewed the law as “invalid in its entirety.”


The decision did significantly restrict one major portion of the law: the expansion of Medicaid, the government health-insurance program for low-income and sick people, giving states more flexibility.


The case is seen as the most significant before the court since Bush v. Gore ruling, which decided the 2000 presidential election.


In addition to its political reverberations, the decision allows sweeping policy changes affecting one of the largest and fastest-growing sectors of the economy, touching nearly everyone from the cradle to the grave.


The political fight over health care remains far from over, with Republicans campaigning on a promise to repeal the law, which they see as an unaffordable infringement on the rights of individuals. The presumptive Republican presidential nominee, Mitt Romney, has promised to undo it if elected.


Chief Justice Roberts wrote that the decision offers no endorsement of the law's wisdom, and that letting it survive reflects "a general reticence to invalidate the acts of the nation's elected leaders."


"It is not our job to protect the people from the consequences of their political choices," he wrote.


The court’s ruling is a crucial milestone for the law, allowing almost all of its far-reaching changes to roll forward. Several of its notable provisions have already taken hold in the past two years, and more are imminent. Ultimately, it is intended to end the United States' status as the only rich country with large numbers of uninsured people, by expanding both the private market and Medicaid.


The key provision that 26 states opposing the law had challenged – popularly known as the individual mandate – requires virtually all citizens to buy health insurance meeting minimum federal standards, or to pay a penalty if they refuse.


Many conservatives considered the mandate unconstitutional under the commerce clause, arguing that if the federal government could compel people to buy health insurance, it could compel them to buy almost anything -- even broccoli, the archetypal example debated during the oral arguments three months ago.


In a complex decision, the court found that Congress’ powers to regulate commerce did not justify the mandate. But it reasoned that the penalty, to be collected by the Internal Revenue Service starting in 2015, is a tax and is not unconstitutional.


Chief Justice Roberts, in the majority, said that the mandate was unconstitutional under the Constitution’s commerce clause. But that did not matter if the penalty that enforces it was constitutional on other grounds.


The court’s four liberals made it clear that they disagreed with the chief justice's view of the commerce clause, but joined him because the effect of his ruling was to let the law stand.


The Obama administration had said in court in 2010 that the mandate could be upheld under the taxation powers, which it called even more sweeping than the federal power to regulate interstate commerce.


It was needed, the government said, because it allowed other provisions to function: those overhauling the way insurance is sold, and preventing sick people from being denied or charged extra for insurance.