The U.S. Supreme Court has handed U.S. President Barack Obama a huge victory by upholding the health care overhaul law Obama helped push through more than two years ago.

The decision means the historic overhaul can continue to go ahead, revolutionizing the way that countless Americans receive medical care and bringing health coverage to more than 30 million uninsured Americans.

Obama was quick to commend the court’s decision.

"They’ve reaffirmed a fund principle, that here in America, the wealthiest nation on Earth, no illness or accident should lead to any family’s financial ruin,” Obama said in a televised address from the White House.

Referring to the months of contentious fighting in the courts and in the public forum over the legislation, Obama added: "It should be pretty clear by now that I didn't do this because it was good politics. I did it because it was good for the country."

In a tight 5-4 decision, the justices ruled Thursday that the “individual mandate” aspect of the Affordable Care Act was constitutional. That mandate compels most Americans to buy health insurance or face a fine.

Critics argued that the federal government didn't have the power to compel anyone to buy health insurance. Supporters said it was within Congress’s powers and a necessary requirement in order to finance the health care plan.

“The Affordable Care Act's requirement that certain individuals pay a financial penalty for not obtaining health insurance may reasonably be characterized as a tax," Chief Justice John Roberts wrote for the court's majority in a 59-page opinion.

"Because the Constitution permits such a tax, it is not our role to forbid it, or to pass upon its wisdom or fairness," he concluded.

Obama’s Republican rival, Mitt Romney, vowed he would see the health overhaul law repealed.

“Obamacare was bad law yesterday. It’s bad law today," he told reporters after the ruling.

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

The court did come down hard on one major portion of the law: the expansion of Medicaid. The court said Congress had exceeded its constitutional power by requiring states to expand the program, which provides health insurance to low-income people.

Many provisions of the law – which was passed by Democrats in March, 2010 -- have already gone into effect, such as:

  •  free wellness exams for seniors
  •  allowing children up to age 26 to remain on their parents' health insurance policies
  •  free mammograms for those on Medicare
  •  health insurance even for those with a pre-existing condition

Republicans were quick to condemn the ruling, saying it would also help to further galvanize their election campaign.

"Today's Supreme Court decision sets the stakes for the November election. Now, the only way to save the country from ObamaCare's budget-busting government takeover of health care is to elect a new president," party Chairman Reince Priebus said in a statement.

The United States spends more on health care than any other country in the world. Most of the country’s 310 million citizens have some kind of health care coverage but about 30 million have no insurance at all.