In a precedent-setting decision almost certain to reverberate through Election Day and beyond, the U.S. Supreme Court, in a 5-4 decision Thursday, upheld President Obama's health-care overhaul, including a requirement that all nonexempt Americans buy health insurance.

The court, in a majority opinion written by Chief Justice John G. Roberts Jr., said the law's requirement that individual Americans buy insurance or be subject to an IRS penalty was constitutional.

It also upheld a provision greatly expanding Medicaid, the health program for the poor financed by the state and federal governments.

But the court struck down a requirement that states lose all of their federal Medicaid funding if they decline to participate in the expansion.

If states decline, that raises the prospect that many uninsured people that the Obama administration hoped to help will not be covered.

"In this case, the financial 'inducement' Congress has chosen is much more than 'relatively mild encouragement' - it is a gun to the head," Roberts wrote.

Political positioning by both parties began shortly after release of the opinion shortly after 10 a.m.

In a statement released by his campaign, Republican presidential candidate Mitt Romney repeated his promise to work to repeal the law if he is elected.

"Obamacare was bad policy yesterday; it is bad policy today," Romney said. "Obamacare is a job killer. Businesses across the country have been asked what the impact is of Obamacare. Three-quarters of those surveyed . . . said Obamacare makes it less likely for them to hire people."

Obama said the ruling "was a victory for people all over this country whose lives will be more secure because of this."

Gov. Corbett said no decision had been made on whether Pennsylvania would participate in the Medicaid expansion, which health experts said could add up to 800,000 people.

"Today's ruling by the Supreme Court to uphold President Obama's health-care law is disappointing," Corbett said in a statement. "If implemented, we will be saddled with a nearly $2 trillion entitlement."

Sen. Bob Casey (D., Pa.) praised the decision. "The fact that the law was upheld means that Pennsylvanians will not lose their coverage under a parents' plan and older Americans will not have to face dramatic increases in prescription drug costs," he said in a statement.

The National Federation of Independent Business, a lead plaintiff in the case, said it was dismayed by the outcome. "Obviously, we are incredibly disappointed," said Dan Danner, president of the federation, which represents small businesses. "The overall health-care bill doesn't work for small business. Their costs are still going up, and we believe the remaining bill makes costs worse, not better."

The complex, 2,700-page law includes multiple initiatives for extending coverage to about 32 million Americans without health insurance.

It requires uninsured Americans above a certain income to obtain coverage, and calls for the creation of state insurance exchanges where individuals can buy coverage, sometimes with federal subsidies. Meanwhile, businesses with 50 or more employees must provide a minimum level of health insurance for each employee, or pay a penalty of $2,000.

It imposes new restrictions on health insurers, barring them from excluding customers with preexisting health conditions, and it requires that all customers be charged the same rates.

Joel Ario, who was Pennsylvania health commissioner in the Rendell administration and is now a health-policy consultant, said the ruling would mean more momentum for the law. "There will be a real head of steam," he said. "It'll be very hard to do anything but continue to move forward."

Proponents of the requirement to buy insurance - the individual mandate - cited the Commerce Clause of the Constitution, which gives the federal government broad power to regulate interstate commerce.

The majority rejected that. But Roberts wrote that the penalty on people who failed to obtain insurance was essentially a tax, and that Congress has the authority to impose it. The penalty was included in the law at the behest of health insurers, who said it would serve as an inducement to buy health insurance.

Roberts, a George W. Bush appointee, was joined in the opinion by Justices Elena Kagan, Stephen G. Breyer, Sonia Sotomayor, and Ruth Bader Ginsburg, all appointed by Democratic presidents. Justices Antonin Scalia, Clarence Thomas, Samuel A. Alito Jr., and Anthony M. Kennedy, appointed by Republican presidents, said they would have struck down the mandate. They disagreed with the majority's assertion that it was a tax.

In its broad sweep, the law also fundamentally restructured and expanded the government's Medicaid health-care program for the poor.

Medicaid for decades has been a health-care benefit available only to people with income below the federal poverty line. States were given wide latitude in designing benefits and eligibility.

The Affordable Care Act greatly expanded the program's size by raising income levels of those who qualify. The law calls for the federal government to pay for all the cost of the expansion, apart from additional administrative outlays, for several years. The states' share of the cost of the expansion will reach 10 percent by 2020.

The 26 states that challenged the law called the Medicaid expansion "coercive" because they risked losing all of their Medicaid funding if they declined to accept the expansion.

The majority, while allowing aspects of the Medicaid expansion to stand, agreed with much of the states' arguments.

"The threatened loss of over 10 percent of a state's overall budget . . . is economic dragooning that leaves the states with no real option but to acquiesce," Roberts wrote.

The Affordable Care Act won final passage on March 21, 2010, after months of partisan debate. It passed without a single Republican vote.

A big reason was the individual mandate, and the penalty, which gradually increases over several years until it reaches $700 or 2.5 percent of income, whichever is greater.

Insurers who argued to keep the individual mandate said it was necessary to compel millions of relatively young and healthy individuals to buy coverage to help offset the cost of insuring people with preexisting ailments that the act required them to cover.

While Republicans vowed to repeal the law, the decision brought a palpable sense of relief to many Democrats. "We spent two years with uncertainty hanging over the bill, so now we can focus on implementation instead of hemming and hawing," said Ezekiel Emanuel, a bioethicist at the University of Pennsylvania and former White House policy adviser whose brother is Chicago Mayor Rahm Emanuel. "I think that is very important."

Contributing were staff writers Jane M. Von Bergen, Stacey Burling, Amy Worden, and Marie McCullough.