Protesters gather at the Los Angeles airport on to demonstrate against President Trump's executive order on immigration. (Konrad Fiedler/Agence France-Presse via Getty Images)

ON SUNDAY, a White House official told reporters that President Trump’s order for temporary travel bans on visitors from seven countries and on refugees, as well as an indefinite ban on Syrian refugees, was “a massive success story in terms of implementation on every single level.” What really happened was a train wreck of decision-making. More worrisome even than the rookie procedural mistakes are the grave potential consequences of an order that’s wrong ethically and strategically.

Mr. Trump’s executive order was not vetted in advance by key Cabinet departments, including Homeland Security, State, Defense and Justice, according to multiple reports. Rather, it appears the order was drafted by a White House coterie. The New York Times reports that Homeland Security Secretary John F. Kelly was on a Coast Guard plane, in the middle of listening to an internal briefing about it, when Mr. Trump signed the order. Confusion erupted as thousands of green-card holders — who are permanent legal U.S. residents — found themselves stranded abroad. At first, the administration said that green-card holders were included in the travel ban; Mr. Kelly later said they should be admitted. Those who were hurt were not terrorists but residents of the United States who had already gone through extensive checking.

The temporary inconvenience and insult are unfortunate but not the worst of this debacle. Mr. Trump’s order for a 90-day halt to entry and four-month pause in refugees included Iraq, the United States’ main ally in the battle that Mr. Trump claims to prioritize, against the Islamic State. As Mr. Trump insults their nation, Iraqi troops are engaged in a grinding struggle, supported by more than 5,000 U.S. troops, to reclaim Mosul. Where is the wisdom in undermining the credibility and standing of their fragile government in Baghdad, which is so essential to the strategic goal of defeating the Islamic State? If the point of Mr. Trump’s action was to improve security, why deepen the dangerous power vacuum in Iraq? In the future, the United States may need battlefield allies such as translators, but Mr. Trump’s order has endangered hundreds of them in Iraq who helped U.S. troops, had been waiting for special visas to the United States and now find themselves in limbo. Who will risk helping Americans if this is the thanks they get?

Yet another counterproductive outcome will be to give terrorist groups such as the Islamic State fresh recruiting material for the calumny that the United States is at war with the Muslim world. A “self-inflicted wound,” said Sens. John McCain (Ariz.) and Lindsay O. Graham (S.C.), among the small number of Republicans with the gumption to speak out against Mr. Trump’s misguided action.

It was an inspiration to see the spontaneous outpouring of public support for refugees and immigrants at airports and in cities across the country, including from lawyers who rushed to help those being denied entry. As Mr. Trump stained the nation’s reputation by barring the doors to deserving refugees, those demonstrators showed the world that thousands of Americans remain committed to the values that have made this nation a beacon for so long.