Yet in the other six countries still on Mr. Trump’s list, his decision to push ahead with the ban only stoked their sense of grievance and discrimination. Regional experts repeated earlier warnings that Mr. Trump’s order handed an easy propaganda victory to enemies and might ultimately weaken American security.
“The idea that this is a Muslim ban has been reinforced even further,” said Maha Yahya, the director of the Carnegie Middle East Center in Beirut. “Islamic State will use this ban to say: ‘I told you so. They only mean you harm. They only see you as the enemy.’”
The six countries left on the list are among the poorest, most chaotic or most politically isolated in the Middle East, so their inclusion carries ostensibly low costs for the Trump administration. Libya has multiple competing governments. Aid officials warn that Yemen, consumed by civil war, is on the verge of famine. Syria’s vicious six-year conflict has left vast urban landscapes in ruins. Somalia has been in a state of rolling chaos since 1991.
Iran does not suffer domestic upheaval, but decades of diplomatic hostility with the West have left it political isolated.
Trump administration officials point out that parts of the banned countries have become havens for Al Qaeda, the Islamic State and other groups, largely as a result of war and chronic instability. But by the same token, studies have shown that the citizens of those countries are more likely to be victims than perpetrators of violence, and have historically not posed a major risk to security in the United States.
According to the New America Foundation, all 13 jihadist terrorists who have killed people in the United States since Sept. 11, 2001, were American citizens or permanent residents. None had ties to the seven countries first singled out by Mr. Trump in January. A federal appeals court, rejecting that order, said his administration had produced “no evidence” linking citizens from the seven affected nations to terrorist acts in the United States.
Among citizens in the banned countries, the sense of injustice is compounded when they look at richer or more powerful neighbors, like Egypt or Saudi Arabia, whose citizens have carried out major attacks in the United States, yet which have escaped Mr. Trump’s censure because their governments are harder to push around.
“You know what they say: When the wife commits adultery, hit the maid,” said Abdel Bari Taher, a Yemeni political analyst speaking by telephone from the war-ravaged country’s capital, Sana. “They are punishing Yemen and others because they are the weak ones. Meanwhile, all the Gulf states that funded terrorism carry on as usual.”
Mr. Taher said he had little doubt Mr. Trump’s ban was driven by domestic political considerations. “He is going after us just to please his right-wing supporters at home,” he said. Nonetheless, he added, it stung.
In Iraq, the initial ban had been taken as a grievous insult from an ally it was supposed to be partnering with in the fight against the Islamic State. When the ban was announced in January, it prompted calls from some officials in Baghdad for Iraq to reciprocate with a ban on Americans entering Iraq, putting the American-backed prime minister, Haider al-Abadi, under political pressure to act.
The plight of military translators who had worked for the United States government and been promised resettlement in the United States provided a further focus for popular outrage.
Mr. Abadi, however, ultimately decided not to impose any restrictions on Americans and instead worked through back channels to have the ban overturned. On Monday, relieved officials said their approach had been vindicated.
“We were hoping for the decision to be reconsidered, and this is what has happened,” said Jasim al-Jaf, Iraq’s minister of migration, in a telephone interview.
Still, it was equally likely that pressure from the Pentagon, which feared damage to the Islamic State campaign, played a significant part in Mr. Trump’s decision.
In the revised executive order issued Monday, Mr. Trump dropped a provision to bar Syrian refugees from the United States indefinitely, but will still freeze all refugee admissions for 120 days.
David Miliband, a former British foreign secretary who leads the International Rescue Committee aid agency, denounced that decision as a “historic assault on refugee resettlement to the United States, and a really catastrophic cut at a time there are more refugees around the world than ever before,” The Associated Press reported.
Ms. Yahya, the analyst, said the refugee decision was part of the growing “moral and reputational toll” from Mr. Trump’s actions in the Middle East. Yet there was not much of an immediate outcry in many countries — possibly because, as elsewhere, citizens were becoming slowly used to a steady stream of far-reaching, yet often perishable, decisions from Mr. Trump’s White House.
Some have been tickled by American news media coverage of the simmering conflict between Mr. Trump and the “deep state” — a phrase more commonly associated with discussions about the Egyptian security services, or Pakistan’s Inter-Services Intelligence spy agency. Yet Mr. Trump’s assault on the news media as an “enemy of the people” has uncomfortable echoes in many countries, and some have taken the parallels to signify that the United States has entered an unwelcome phase.
“Trump has taken America from its ivory tower to the level of a rotten banana republic,” Mohamed Rageh Roweis, a Palestinian analyst, wrote on a Twitter.
Even in unaffected countries, the ban has stoked the belief that the true goal of Mr. Trump and senior advisers like Stephen K. Bannon is to pursue a civilizational war against Muslims, rather than to combat terrorism.
“It doesn’t make any sense,” said Mustapha Kamel al-Sayyid, a political-science professor at Cairo University. “These terrorist groups are multinational organizations. If they want to attack the United States, they don’t have to send people from these six countries. They can just find someone from another country.”