WASHINGTON — With the Supreme Court likely to render judgment on President Obama’s health care law this week, the White House and Congress find themselves in a position that many advocates of the legislation once considered almost unimaginable.

In passing the law two years ago, Democrats entertained little doubt that it was constitutional. The White House held a conference call to tell reporters that any legal challenge, as one Obama aide put it, “will eventually fail and shouldn’t be given too much credence in the press.”

Congress held no hearing on the plan’s constitutionality until nearly a year after it was signed into law. Representative Nancy Pelosi, then the House speaker, scoffed when a reporter asked what part of the Constitution empowered Congress to force Americans to buy health insurance. “Are you serious?” she asked with disdain. “Are you serious?”

Opponents of the health plan were indeed serious, and so was the Supreme Court, which devoted more time to hearing the case than to any other in decades. A White House that had assumed any challenge would fail now fears that a centerpiece of Mr. Obama’s presidency may be partly or completely overturned on a theory that it gave little credence. The miscalculation left the administration on the defensive as its legal strategy evolved over the last two years.