President Obama and his re-election team must have started the week with great trepidation as the Supreme Court prepared to release decisions on immigration and health care reform, his signature domestic program.

But the president won two big victories at the Court this week: The controversial Arizona immigration law was mostly struck down and the even more controversial Affordable Care Act was mostly upheld in a surprise decision authored by Chief Justice John Roberts himself.

As I’ve written, immigration has been a huge win for the president. His announcement a few weeks ago that he would not deport some children of illegal immigrants gave him a big boost among Hispanics, a key voting group in many swing states. By waging a successful battle against much of the Arizona law, the president shored up support in that community.

Republican nominee Mitt Romney doubled down on the anti-immigrant position he staked out during the GOP primaries. Romney is clearly choosing the nativist elements of the Tea Party over Hispanics, so it’s no surprise he’s trailing the president by 30-40 percentage points among Latino voters. He may lose the election over that, but he has little choice. This is one issue he just can’t Etch a Sketch his way out of.

The health care decision, I think, was a more qualified victory for the president. Psychologically it was huge; had the Court thrown out the Affordable Care Act, which in many ways has defined his presidency, it could have dealt a mortal blow to his re-election chances.

President Obama speaks from the White House after the Supreme Court's decision on health care reform.

But the Supreme Court’s ruling had a galvanizing effect on Republicans, renewing the Tea Party’s energy and suppressing whatever remaining doubts they might have had about Romney. The former Massachusetts governor had spent the whole primary season distancing himself from his own biggest achievement—a health care plan with an individual mandate that served as the model for Obamacare.

So, when the decision came down, he was well positioned to respond, and his speech, with the US Capitol in the background, was a good one. (You can watch the video here.)

Let’s make clear that we understand what the Court did and did not do. What the Court did today was say that Obamacare does not violate the Constitution. What they did not do was say that Obamacare is good law or that it’s good policy.

What the Court did not do on its last day in session, I will do on my first day if elected President of the United States… I will act to repeal Obamacare.

That pitch and the Court’s decision helped boost Romney’s campaign coffers by $4.6 million in 24 hours, because conservatives who want health care reform overturned now have only one way to accomplish that—a Republican president and a Republican Senate with a big enough majority to sustain a repeal.

That will energize them to vote in November, and the Court’s other big vote this week—to uphold their 2010 Citizens United decision—should help Republican Super PACs outraise Democrats, another advantage for Romney and the GOP.

But had the Supreme Court declared health care reform unconstitutional, it would have made Obama’s presidency look like a failure and raised new questions about his leadership. For an incumbent, that’s a recipe for defeat (Gerald Ford in 1976, Jimmy Carter in 1980), and by avoiding that, the president must view the week at the Supreme Court as a big win.