Barack Obama narrowly escaped a damaging rejection by the U.S. Supreme Court Thursday, when the Justices ruled that the health care reforms commonly known as “Obamacare” passed constitutional muster.

Writing for the majority, Chief Justice Roberts ruled that the requirement that all Americans buy health insurance or pay a penalty starting in 2014 could be upheld under the constitutional right of the federal government to levy taxes. “Our precedent demonstrates that Congress had the power to impose the exaction in Section 5000A under the taxing power, and that Section 5000A need not be read to do more than impose a tax,” the majority opinion read. “This is sufficient to sustain it.”

The political parties responded immediately to the ruling. Republican National Committee Chairman Reince Priebus tweeted, “Just elect Romney. We need #fullrepeal.” The Democratic National Committee released a web video that shows Romney praising the idea of an individual mandate, mostly in the context of a state mandate, under a misleading banner that suggests Romney was responding to the current ruling. It can be seen here.

A recent RAND study concluded that 91% of the country’s non-elderly adults would receive insurance coverage under the law as it was written, compared to 81% without any policy change. If the so-called “individual mandate” instructing all Americans to buy insurance was voided but the rest of the law had remained in place, RAND, concluded that 87% of the non-elderly population would have insurance. By stripping out the mandate, 12 million Americans would have likely opted not to buy insurance, or would not have been able to afford insurance.

Congress and the White House spent more than a year obsessing over the details of health care reform, but for most of that time the constitutionality of the bill, and the insurance requirement in contained, was not an issue. “I believe that there is a bipartisan consensus to have individual mandates,” said Iowa Sen. Chuck Grassley, one of the top Republican negotiators, in June of 2009, during an interview with Fox News.

Senate Republicans did raise objections to the mandate in December of 2009, but that effort, in the form of a constitutional point of order, was defeated in a party-line vote. The press coverage at the time noted that at least seven of the 39 Republicans who voiced opposition to the mandate as unconstitutional had earlier supported the same approach for expanding insurance coverage.

On the day Obama signed health care reform into law, Obama senior adviser David Axelrod expressed little concern about the coming legal challenges. “First of all, every single major piece of legislation that’s ever been passed in this country has engendered lawsuits. That’s the nature of our system, and we expected that,” Axelrod told the ABC network morning show, Good Morning America. “We’re not concerned about these lawsuits.”

At the time, Democrats boldly predicted that the popularity of the new law would grow over time, as Americans learned more about it. But the two years afterward did not go as they had planned. Federal appellate courts split on whether the individual mandate was constitutional, with two affirming its legality, one rejecting it, and a fourth saying the issue could not be decided until after the law was in fully implemented and taxpayers were paying penalties.

The court of public opinion has also had mixed results, driven in part by $235 million in television advertising against the law since its passage. A recent Pew Research Poll found that 48% of the public disapproved of the law, while 43% approved. But perhaps more notable was the degree of feelings—35% “strongly” opposed the law, while only 26% “strongly” supported it.

Polling also shows that more than two years after the law’s creation, the American people remain deeply confused about what the sprawling piece of legislation contains. Only 18% of Americans said they understood the law very well, and 31% say they understood it “not too well” or “not at all well.”

Officially called the Affordable Care Act, the law attempted to do many things at once: Expand health insurance coverage, reduce the rate of rising long-term costs, regulate the kind of policies insurance companies can offer, prevent them from discriminating based on customers’ health, and make changes to Medicare that increased prescription drug coverage for some seniors and cut funds from private Medicare plans.

In April, President Obama expressed some exasperation at the difficulty faced by his supporters during oral arguments at the Supreme Court. “I’m confident that the Supreme Court will not take what would be an unprecedented, extraordinary step of overturning a law that was passed by a strong majority of a democratically elected Congress,” he said, at a press conference in the Rose Garden. “And I’d just remind conservative commentators that for years what we’ve heard is the biggest problem on the bench was judicial activism or a lack of judicial restraint, that an unelected group of people would somehow overturn a duly constituted and passed law. Well, this is a good example.”

More recently, Obama and his aides have been more restrained in their public comments, as they awaited the court’s decision. “The two unfathomable things are what the court will do and what the politics of that will be,” an Obama campaign official said last week. “I don’t think anybody really knows the answer to those questions. But the thing we do know is that there are millions and millions of people who are benefiting from the affordable care act already.”

At the White House, officials have said little about their plans, though they assured reporters that they were prepared for any outcome from the Supreme Court. The political fallout from the ruling was likely to be felt on two levels: its policy implications and its reflection on the President’s own leadership abilities.

For the White House, the latter had more concern, even in an election that seemed destined to hinge upon economic concerns. In recent weeks, Obama’s Republican rival for the White House, Mitt Romney, has argued that Obama wasted valuable time by pursuing health care reform rather than focus on jobs. “The first three-and-a-half years of this President’s term will have been wasted on something that has not helped the American people,” he said of the possibility that the court overturns the law.

Obama did devote most of his first two years in office fighting to pass health care reform, and as a result decided not to pursue other priorities, including immigration reform and an energy bill that would have imposed new restrictions on carbon pollution. One fear, among Democratic political strategists, was that a rejection of his signature issue would reflect poorly on public perception of his qualification for reelection.

Barack Obama’s own reputation as a strong leader tumbled precipitously in the late summer of 2011 after the debt ceiling debacle, with the share of the country who saw him as a strong leader falling from 60% in April of 2011 to just 49% in October, according to a national Quinnipiac Poll. By April of 2012, his rating had fully recovered.

On the specific policies, the White House and the campaign have promised to continue promoting the law among specific groups of voters who will benefit. For much of the last two years, the Obama’s Chicago campaign apparatus in concert with the White House had been selling Obamacare through careful microtargeting, informing voters — limits on insurance company profits, coverage options for adult children, increased Medicare coverage for prescription drugs, and guarantees of certain preventative care, for example.

A section of the campaign website allows voters to figure out exactly how the law can benefit them, by age, income, gender, family size and insurance status. “We have sent out 5 million pieces of mail on health care,” the same campaign official said last week. “We will communicate vigorously on that issue.”