WASHINGTON — The night his administration’s Affordable Care Act passed in 2010, President Obama described the victory the way he hopes historians will: as a “stone firmly laid in the foundation of the American dream.”

But Mr. Obama’s prospects for a legacy of expanding health care coverage in the United States for generations have rarely seemed as uncertain as they do today. The Supreme Courtis expected to rule by the end of the month on a critical provision of the Affordable Care Act — insurance subsidies for millions of Americans — and even Mr. Obama’s closest allies say a decision to invalidate the subsidies would mean years of logistical and political chaos.

“Will that have, in the history books, an impact on the president?” said Kathleen Sebelius, who as secretary of health and human services led the fight in Congress to pass the health care law. “I’m sure. I know Republicans like to focus on how this would be a great blow to the president. But for heaven’s sake, they would have a mess on their hands.”

GRAPHIC

The Health Care Supreme Court Case: Who Would Be Affected?

A look at the major issues at stake in King v. Burwell and the results of the ruling.

OPEN GRAPHIC

In the Supreme Court case, King v. Burwell, conservatives have challenged the federal government’s right to subsidize premiums for people who signed up for insurance through a federally run health marketplace. If the government loses, more than 6.4 million of those policy holders could see their premiums triple, or worse. Insurance companies could abandon marketplaces across the country. Mr. Obama’s attempt to engineer a private-sector solution to the country’s health insurance crisis could all but collapse.

“It would be a huge, devastating blow to the country,” said Tom Daschle, a former Democratic senator from South Dakota. “It is cataclysmic, from an insurance perspective.”

Health care experts say the elimination of subsidies would collapse the individual health care marketplaces in dozens of states and largely mean the end of the requirement to buy insurance in those places. But other parts of Mr. Obama’s law should survive, including the guarantee of coverage regardless of pre-existing conditions, an expansion of Medicaid, rules allowing young people to be covered by their parents’ insurance until age 26 and requirements that new health plans cover certain preventive care.

Republicans, who control Congress, say they are aware that Americans may look to them for a solution, and could blame them if bickering and gridlock get in the way. But many say they are gleeful that the court may do with a single decision what Republican lawmakers could not accomplish in five years: Cripple one of Mr. Obama’s signature achievements.

“This is the beginning of the end of the Affordable Care Act,” Representative Paul Ryan of Wisconsin, the chairman of the House Ways and Means Committee, said in an interview.

Mr. Ryan said Republicans were preparing legislation that would protect policy holders from losing subsidies until 2017, when Mr. Obama would no longer be in office. At that point, Mr. Ryan said, Republican lawmakers would try to work with the new president to fully dismantle the health care law and replace it with a more conservative approach.

“The key is to get into 2017,” Mr. Ryan said. “That’s why the court ruling is so devastating to him. It will expose this law, and make it certain that Congress will be rewriting this law fully once he’s gone.”

The president’s allies still hold out hope that the court will not undermine the president’s health care law, noting that even some Republicans believe that Congress intended to allow the subsidies when it passed the legislation. Mr. Daschle said he put the odds of the court’s allowing the subsidies to continue at about 50-50.

Mr. Daschle said Mr. Obama had helped bring about other long-term changes to the country’s health care system that would endure even if the court struck down the subsidies. As an example, he said, hospitals are moving away from the fee-for-service model of payment that has helped drive up the cost of health care.

“There’s an inexorable quality to all of this,” Mr. Daschle said. “With each week, each passing month, each year, it becomes an integral part of the health care system.”

Making the changes part of the fabric of the American health care system was the essence of the White House strategy in 2009 and 2010. Mr. Obama and his top aides, led by Rahm Emanuel, who was the White House chief of staff, pushed Congress to pass a health care overhaul quickly to capitalize on Democratic control of Capitol Hill. They also wanted Mr. Obama to have time to put into action whatever law passed.

Over time, they believed, the changes would burrow their way into public expectations of what government should provide, much as Medicare and Social Security, and, in the process, become a major influence on the way Mr. Obama is remembered.

“For millions of Americans, the Affordable Care Act is embedded and is a reality,” said David Axelrod, who was a senior adviser to Mr. Obama when the health care law was debated in the first term. “That’s not something to be trifled with.”

Polling suggests that public opinion is split about the health care law. In the latest New York Times/CBS News poll, 47 percent of those surveyed said they approved of the law, while 44 percent said they disapproved.

Still, most Americans do not appear eager to see the law’s most critical benefits overturned by the court. In the survey, 70 percent said they thought that the government should continue to provide financial assistance to buy health insurance. That percentage included nearly nine in 10 Democrats, three-quarters of independents and four in 10 Republicans. If the court rules against the government, nearly two-thirds of those surveyed said, Congress should pass a law to reinstate the subsidies.

Even so, a ruling against the government by the Supreme Court would mean years of uncertainty for the Affordable Care Act.

Mr. Obama would leave office in January 2017 without knowing whether millions of people would remain stuck in the ranks of the uninsured. After years of blocking Republican attempts to tinker with the health care law, he would depart knowing that it remained under attack by his opponents. But it would be up to the next president and Congress to decide whether, and how, to fix it or abandon it altogether.

For the president’s closest allies, that prospect is galling.

Mr. Axelrod, the protector of Mr. Obama’s political brand, said the president was not “sitting there thinking about his legacy.”

“He’s thinking about what’s the best thing for the country,” Mr. Axelrod said.

But he is also a veteran campaign operative who spent much of the previous decade trying to get Mr. Obama into the Oval Office. He said the history books would record the president’s efforts to pass a health care law against tremendous opposition, and the effect that the law has already had on millions of Americans.

“The reality is that people’s lives have been affected in a very positive way,” Mr. Axelrod said. “That’s not a legacy that’s going to be erased easily.”

Ms. Sebelius said she worried most about the people who have been able to afford health insurance for the first time because of the subsidies. Some of those people would have to stop treatment if they suddenly lost their insurance because of the court’s decision.

“That, to me, is what would be so wrenching and heartbreaking,” Ms. Sebelius said. “There are people whose lives had changed forever for the better. I don’t know what then happens to them.”

But Mr. Ryan, who vowed to unwind the Affordable Care Act when he was a vice-presidential candidate in 2012, predicted the court would rule against the law.

“I think they cut corners trying to get this bill into law,” Mr. Ryan said. “Those chickens are coming home to roost.” If the court rules against Mr. Obama, he added, “I think it’s a huge blow to his efforts to create a le