The Supreme Court’s momentous decision Thursday to uphold the Affordable Care Act prompted swift responses from the two presidential candidates, moving the debate squarely into the political sphere and setting it up to figure prominently for the remainder of the campaign.

President Obama, speaking from the East Room of the White House, celebrated the Supreme Court’s decision and offered a detailed defense of the landmark legislation. Although he said any discussion of the politics of the decision “completely misses the point,” his effort to sell the law made clear that the battle over its fate — and its role in the campaign — are far from over.

“I didn’t do this because I thought it was good politics,” Obama said, touting the act’s provisions to protect patients with preexisting conditions, to allow children up to age 26 to remain on their parents’ plans and to require insurers to provide free preventive screenings. “I did it because I believed it was good for this country.”

Obama said that even as implementation of the act continues, it can be improved upon. But the court ruling allows the country to avoid, Obama said, going back to “fight the political battles of two years ago,” when the law was passed.

Mitt Romney, speaking on the roof of an office building in downtown Washington, the Capitol behind him and a lectern in front reading “Repeal & Replace Obamacare,” also made clear that the conversation isn’t over. He said the Supreme Court’s ruling doesn’t change the fact that the act is “bad law” and “bad policy.”

“What the court did not do on its last day in session, I will do on my first day as president, and that is, I will act to repeal Obamacare,” the presumptive Republican presidential nominee said.

Romney avoided criticizing the Supreme Court, taking aim instead at the Affordable Care Act and the president. Although he promised to retain some of the act’s more popular provisions, including protections for patients with preexisting conditions, he excoriated the rest and called the law a “job-killer” overall.

The 5 to 4 decision was a huge win for Obama, for whom the health-care legislation is a signature achievement. The ruling also undermined the central argument being made by Romney and other Republicans: that the act’s central provision, the individual mandate, is unconstitutional.

Senior administration officials described how the president learned of the Court’s decision. At 10 a.m., Obama was watching a television in the “outer oval,” just outside the Oval Office, that had a four-way split screen with the four major news channels. He saw CNN and Fox misreport that the Supreme Court had overturned the individual mandate. He was described as calm. But within a couple of minutes, White House counsel Kathryn Ruemmler and Chief of Staff Jack Lew came in to tell him the actual decision.

Ruemmler and Lew had been following the proceedings on television and on SCOTUS Blog, and the White House had a lawyer at the court, administration officials said. Ruemmler first signaled to Obama with two thumbs up and then told him the good news of the 5 to 4 vote. Obama showed a bit of cognitive dissonance because he had seen the early erroneous reports, which were still on the air as Ruemmler told him the actual decision. The official said Obama was very happy and hugged Ruemmler, and his first call was to Solicitor General Don Verrilli to thank him. Ruemmler later had a more-detailed second conversation with Obama after she had read the ruling to break down the vote and the opinions for him.

The ruling provided challenges and opportunities to both sides. Obama’s campaign manager, Jim Messina, put out a fundraising appeal before the ruling was even issued. And Andrea Saul, a Romney spokeswoman, said the Republican’s campaign had raised $200,000 in the first hour following the ruling.

Americans for Prosperity, the conservative, tea-party-friendly advocacy group, offered an additional clue Thursday as to how Republicans would try to use the Court’s ruling to their advantage. In an interview with Politico, an AFP leader said the group plans to launch a $9 million ad campaign linking Obama to the Supreme Court’s characterization of the law’s individual mandate as a tax.

The challenge for Obama to move public opinion on whether the Affordable Care Act was a good idea remains high. Republicans, and Romney, will continue to push to repeal the act, and if that sentiment remains high among voters, it could affect the outcome in November.

Still, it remains to be seen whether Romney wants a protracted conversation about repealing the act. The former Massachusetts governor is unlikely to want to remind voters that he led the effort in that state to pass a health-care law, including an individual mandate, that was a basis for the federal legislation. Romney also has been clear that he wants to keep the conversation focused squarely on the economy, and an extended debate about the Affordable Care Act would detract from that.

Obama is in a similar position. At the end of his remarks at the White House, he said: “Now’s the time to keep our focus on the most urgent challenge of our time: Putting people back to work.”

For days, the White House has been issuing a series of defenses of the Affordable Care Act.

On a two-day swing through Virginia this week, Romney laid out how he would respond to either scenario possible from the Supreme Court.

“As you know, the Supreme Court is gonna be dealing with whether or not Obamacare’s constitutional. If it’s not, if Obamacare is not deemed constitutional, then 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,” Romney said Tuesday to a crowd of 1,500 in Salem. “If it is deemed to stand, then I’ll tell you one thing. Then, we’ll have to have a president, and I’m that one, that’s gonna get rid of Obamacare. We’re gonna stop it on day one.”

Staff writer David Nakamura contributed to this report.