“We have the right strategy and we’re going to see it through,” Mr. Obama told reporters as he wrapped up a summit meeting with world leaders before flying to the Philippines. He has consistently said that it would take time, he noted, and he would not change that strategy simply because of domestic pressure. “What I do not do is take actions either because it is going to work politically or it is going to somehow, in the abstract, make America look tough or make me look tough.”

If he did not gratify a public hunger for retribution, or at least the language of it, the president gambled that his position was actually closer to the broader American reluctance to get entangled in another land war in the Middle East. Sending large numbers of American ground troops to fight the Islamic State, also known as ISIS, ISIL or Daesh, would repeat what he sees as the error of the Iraq invasion of 2003 without solving the problem at hand.

“That would be a mistake, not because our military could not march into Mosul or Raqqa or Ramadi and temporarily clear out ISIL, but because we would see a repetition of what we’ve seen before,” Mr. Obama said. Victory over terrorist groups, he said, requires local populations to reject the ideology of extremism “unless we’re prepared to have a permanent occupation of these countries.”