“The problem in Washington, besides every piece of legislation having its own special interest group, is that bills are purposely written to be complicated,” said Michael Dubke, who briefly served as White House communications director under Mr. Trump. “And complicated is hard to unwind.”

Mr. Trump could, of course, simply abandon the Iran deal as he did with the trade and climate agreements, and he may yet. But while that may be satisfying, he has been told by advisers that the United States would find it harder to pressure the clerical leadership in Tehran without allies, and so he has not risked alienating them with a unilateral move.

John R. Bolton, a former ambassador to the United Nations and a strong critic of the nuclear deal, said time is on Iran’s side and Mr. Trump should find a way to persuade the allies. “We need to explain this to the Europeans,” he said. “They may find it hard to accept, but plain speaking is still an American virtue, occasionally even in diplomacy.”

As for health care, Mr. Trump chastised Democrats on Tuesday for not going along — “Dems totally obstruct,” he tweeted — but he made no serious effort to reach out to them during the months he has targeted Mr. Obama’s health care program, nor would it have been realistic to expect them to join a drive to repeal what they consider to be one of their proudest achievements. While he did lobby Republicans, some said he did not make a serious enough effort to do so. The White House devoted its public message this week to made-in-America themes rather than health care.

Vice President Mike Pence said on Tuesday that lawmakers should either repeal Mr. Obama’s program outright or return to the legislation that has now failed. “Either way, inaction is not an option,” he said in a speech to members of the National Retail Federation in Washington. “Congress needs to step up. Congress needs to do their job, and Congress needs to do their job now.”

For Mr. Trump, the failure seemed to compound the problems of a presidency that has been dominated by Twitter-fueled controversies and investigations into contacts with Russia during and after last year’s election that have left him with the support of just 36 percent of the public, the lowest of any president at this point in seven decades.