“They didn’t do it,” he repeated twice more.

Nikki R. Haley, the United States ambassador to the United Nations, echoed Mr. Mattis, telling lawmakers during a hearing that Mr. Trump’s warning had worked.

“I think that by the president calling out Assad, I think by us continuing to remind Iran and Russia that while they choose to back Assad, that this was something we were not going to put up with,” she said. “I would like to think that the president saved many innocent men, women and children.”

At the White House, officials said the president came up with the idea to issue the blunt statement by the office of the press secretary, Sean Spicer, on Mr. Trump’s behalf. But they insisted that reports about military and intelligence officials not being aware of the statement before it was released were “simply false.”

Sarah Huckabee Sanders, the principal deputy press secretary, told reporters in an off-camera briefing on Wednesday that Mr. Trump proposed issuing a statement after being presented with information indicating that the Assad government might attack again with chemical weapons. She declined to provide details about that evidence, or say who provided it to Mr. Trump.

Ms. Sanders said that senior administration officials, including the national security adviser, the director of national intelligence and the director of the C.I.A., were present at a regularly scheduled security meeting when Mr. Trump proposed the idea of a statement. And she said that those officials “remained in the loop throughout the drafting process” of the president’s statement.