Until Thursday, it wasn’t clear that future generations would have much to assess about the enduring legislative legacy of the Obama presidency.

There had been no victory on climate change, no shift in the way Washington worked, no grand bargain to cut the deficit. And it looked as if a hostile Supreme Court was going sour on the Obama administration’s one big policy accomplishment — the marquee law achieving the liberal movement’s decades-long goal of near-universal health care.

So when the justices announced their 5 to 4 ruling upholding the health law, they suddenly put Obama back on a path to achieving the historic significance he promised in his campaign and so deeply desires.

The ruling, however, may well complicate the president’s quest for the biggest affirmation of all — a second term — by memorializing a broadly unpopular law. The measure that came to be known derisively as “Obamacare” inspired the rise of the tea party, helped spawn a voter backlash that handed Republicans the House just two years after Obama’s convincing 2008 election victory, and now stands as one of the GOP’s main arguments for ousting the president in November.

Obama will have to explain the law’s central provision — a requirement that all Americans buy health insurance or pay a penalty — in the face of aggressive efforts by Mitt Romney and other Republicans to portray the mandate as an unfair middle-class tax increase. Obama has categorically denied that it is a tax increase, but his administration’s legal defense of the bill and now the Supreme Court ruling say otherwise, setting up a rhetorical tightrope for a president who vowed to cut middle-class taxes.

Moreover, the administration will be forced to fend off criticism from experts that the law will achieve little, if any, of the cost containment that was the initial White House rationale for its passage.

The ruling also included a surprising, and potentially costly, defeat for the Obama administration in allowing states to opt out of the health-care law’s expansion of Medicaid coverage. That might lead to more people signing up for newly created insurance exchanges, which would add to the federal cost.

Nevertheless, Obama — who has drawn scorn from critics for comparing himself to the greats, from ­Abraham Lincoln to Franklin D. Roosevelt — can finally include his name on the list of those who have secured landmark legislation. One senior aide told reporters Thursday that the law was on a par with Medicare and Social Security in its lasting importance.

“Today, I’m as confident as ever that when we look back five years from now, or 10 years from now, or 20 years from now, we’ll be better off because we had the courage to pass this law and keep moving forward,” Obama said in an address to the nation from the East Room of the White House hours after the ruling.

The short-term political gains were clear to strategists and experts. The decision undercut a key GOP attack line — that the president wasted two years pursuing an unconstitutional law rather than fixing the economy.

The ruling also offered the White House, and Obama’s reelection campaign, a chance to try to undo some of the lasting political damage from the 2009-10 health-care debate. Republicans successfully painted the law as a big-government power grab, but administration officials signaled Thursday that they intend to mount a new effort to portray the law as a boon to consumers — particularly African Americans, Hispanics and other groups crucial to Obama’s political coalition.

The decisive vote

Had Chief Justice John G. Roberts Jr. cast his decisive vote the other way, siding with court conservatives to invalidate the law, Obama would have found himself in a much less comfortable place.

Without a lasting legislative achievement on the books, Obama’s only enduring accomplishment might have been his election as the nation’s first black president, something that occurred before he took office.

Obama’s place in history was always assured by that fact alone. But he and his aides have often tried to play down the racial component of his presidency. And dating to his days as a candidate, Obama has made clear that he aspires to be seen more as an architect of grand policy ideas.

When he wrapped up his nomination fight with Hillary Rodham Clinton in June 2008, Obama laid out that goal in near-grandiose terms, predicting that future generations would look back to his election as the moment when “we began to provide care for the sick and good jobs to the jobless” and when “the rise of the oceans began to slow and our planet began to heal.”

Though the health-care “individual mandate” now stands as the signature accomplishment of the Obama presidency, it was in many ways an unlikely cause on which to stake his legacy.

As a state senator in Illinois, Obama told audiences that his ideal plan would be a “single-payer” system, a proposal long pushed by liberals that would essentially expand Medicare-type benefits to all Americans.

When the Democrats took control of the state Senate in the 2002 election, Obama made a call the next morning to Jim Duffett, executive director of the Illinois advocacy group Campaign for Better Health Care.

“We want to move forward to pass universal health care,” Duf­fett recalled Obama saying. The two met a few days later in Obama’s office on Chicago’s South Side and mapped out a plan to push legislation.

But five years later, as Obama mounted a presidential campaign, he did not initially emphasize health care.

Advisers recalled later that Obama was embarrassed at a Las Vegas forum when his two top rivals for the Democratic nomination, Clinton and John Edwards, laid out health-care proposals that were greeted warmly by the crowd.

Morgan Miller, then a 23-year-old union organizer in the audience, called on to ask a question, told Obama that his Web site contained no information on the issue. “What really are your top issues when you want to talk about health care?” she asked him.

Obama offered only vague ideas, pledging to convene roundtable discussions before rolling out his plan. He went on to oppose the individual mandate, saying that “in some fashion, everybody will be forced to buy health insurance” if a mandate is enacted.

But as he pursued health-care legislation as president, Obama decided to back the idea. It seemed a viable compromise — not as far to the left as the “public option” pushed by many liberals — to prevent people who could afford insurance from forcing other Americans to pay for their health care.

The White House reacts

“I knew it wouldn’t be politically popular,” Obama said Thursday of the individual mandate.

In a direct dig at Romney, who supported the mandate as part of the health-care overhaul he designed as governor of Massachusetts, Obama added: “This idea has enjoyed support from members of both parties, including the current Republican nominee for president.”

The ruling Thursday prompted an emotional outburst in the West Wing, with Obama and his aides embracing one another in celebratory hugs. They were thankful for an unexpected ally.

As a senator, Obama had opposed Roberts’s nomination as chief justice, and as president, he lectured the court over a campaign finance ruling. Now, in some respects, Obama owes his legacy to Roberts.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.

To pause and restart automatic updates, click "Live" or "Paused". If paused, you'll be notified of the number of additional comments that have come in.

Comments our editors find particularly useful or relevant are displayed in Top Comments, as are comments by users with these badges: . Replies to those posts appear here, as well as posts by staff writers.