Media playback is unsupported on your device Media caption Obama: "A victory for people all over this country"

The US Supreme Court has said President Barack Obama's landmark healthcare reform act is constitutional.

The court upheld a core requirement known as the "individual mandate" that Americans buy insurance or pay a fine.

Of the nine justices on the bench, Chief Justice John Roberts' vote was decisive in the Supreme Court's 5-4 ruling in favour of the law .

The ruling comes months before the US election, with Republicans vowing to push for a repeal of the bill.

Healthcare is a deeply polarising issue in the US and Republicans strongly opposed Mr Obama's legislation.

In our view, the entire Act before us is invalid in its entirety Justice Anthony Kennedy, Dissenting opinion Americans react to rulingHealthcare decision: Key excerpts

The state of Florida, along with 12 other states, filed a legal challenge to the bill minutes after Mr Obama signed The Patient Protection and Affordable Care Act (ACA) into law in March 2010.

They were later joined by 13 more states, the National Federation of Independent Businesses and several individuals.

'Implement and improve'

Speaking afterwards, President Obama called the court's decision a victory for the country, saying people would not need to "hang their fortunes on chance" or fear financial ruin if they became sick.

"The highest court in the land has now spoken. We will continue to implement this law and we'll work together to improve on it where we can," Mr Obama said, speaking at the White House.

"What we won't do - what the country can't afford to do - is re-fight the political battles of two years ago or go back to the way things were. With today's announcement, it's time for us to move forward.

Analysis This ruling means President Obama avoids a humiliating shellacking and does not have to make a near impossible decision about how to replace an eviscerated law. He can wipe his brow and breath a huge sigh of relief. But that does not mean it is bad news for Mitt Romney. The only way to get rid of the law is to elect him. He now has a cause that not only fires up his supporters but may also appeal to all important swing voters. It is, as he has said, a choice.

"We will be better off because we had the courage to pass this law," Mr Obama added.

Republican presidential candidate Mitt Romney said the healthcare bill was "bad law yesterday, it's bad law today".

"This is a time of choice for the American people. If we're going to get rid of Obamacare we're going to have to replace President Obama. My mission is to make sure we do exactly that."

He called "Obamacare" a tax rise that would add to the national debt, a "job-killer", and said it would put the federal government "between you and your doctor".

Congressional leaders also responded quickly to the verdict. Senate Minority Leader Mitch McConnell, a Republican, said: "We've passed plenty of terrible laws around here that were constitutional."

On the Senate floor, he said the only way to fix the law was "full repeal".

Meanwhile, the Senate's Democratic majority leader, Harry Reid, disagreed: "Now that this matter is settled, let's move on to other things. Like jobs."

'Triggering a tax'

The mandate was eventually upheld by the justices, citing the taxation powers granted to Congress by the US constitution.

Who's uninsured?

Nearly 50 million, or 16.3% of Americans are uninsured

million, or of Americans are uninsured By ethnicity, the rate of those who lack insurance is

15.4% White

White 20.8% Black

Black 18.1% Asian

Asian 30.7% Hispanic

Hispanic Source: US Census Bureau

Chief Justice Roberts said: "We do not consider whether the Act embodies sound policies. That judgment is entrusted to the Nation's elected leaders.

"We ask only whether Congress has the power under the Constitution to enact the challenged provisions."

A majority of justices agreed that the penalty individuals must pay if they refuse to buy health insurance falls within Congress' power to levy taxes, upholding the "individual mandate".

"The mandate can be regarded as establishing a condition - not owning health insurance - that triggers a tax - the required payment to IRS," Justice Roberts wrote.

The government's main argument was that the law was legal under Congress' ability to regulate "interstate commerce" - but a majority of justices did not agree with this view.

Four dissenting justices said that limits on the power of Congress to regulate commerce and raise taxes "cannot be such as will enable the Federal Government to regulate all private conduct and to compel the States to function as administrators of federal programs."

"That clear principle carries the day here," they added.

In an opinion written by Justice Anthony Kennedy, the dissenting justices went further, to say: "In our view, the entire Act before us is invalid in its entirety."

Medicare clause limited

While the court described the penalty as a tax, it did not invoke a law that could have prevented the justices from ruling on the case.

Healthcare verdict Individual mandate upheld

Expansion of Medicaid limited but not struck down

Five justices voted to uphold the law: John Roberts (chief justice), Ruth Bader Ginsburg, Elena Kagan, Sonia Sotomayor, Stephen Breyer

Four justices dissented: Antonin Scalia, Anthony Kennedy, Clarence Thomas, Samuel Alito The Supreme Court's opinion

Under a law called the Anti-Injunction Act, taxes cannot be legally challenged until after they have been levied. This could have delayed a verdict till 2015 - after the "individual mandate" comes into effect and the first round of penalties have been paid.

They were also not required to rule on the issue of "severability", which would determine whether other parts of the healthcare law could stand even if the mandate was struck down.

In addition to the individual mandate, the Supreme Court was asked to consider another part of the law that deals with the expansion of Medicaid, a government healthcare programme for low-income citizens.

The court ruled to limit that provision but did not strike it down altogether, saying Congress could place conditions on the use of federal funds.

"What Congress is not free to do is to penalize States that choose not to participate in that new program by taking away their existing Medicaid funding," the Supreme Court's opinion said.

Some hospital and health insurance stocks were trading higher in the wake of the Supreme Court's ruling.