The order lacks any logic. It invokes the attacks of Sept. 11 as a rationale, while exempting the countries of origin of all the hijackers who carried out that plot and also, perhaps not coincidentally, several countries where the Trump family does business. The document does not explicitly mention any religion, yet it sets a blatantly unconstitutional standard by excluding Muslims while giving government officials the discretion to admit people of other faiths.

The order’s language makes clear that the xenophobia and Islamophobia that permeated Mr. Trump’s campaign are to stain his presidency as well. Un-American as they are, they are now American policy. “The United States must ensure that those admitted to this country do not bear hostile attitudes toward it and its founding principles,” the order says, conveying the spurious notion that all Muslims should be considered a threat. (It further claims to spare America from people who would commit acts of violence against women and those who persecute people on the basis of race, gender or sexual orientation. A president who bragged about sexually assaulting women and a vice president who has supported policies that discriminate against gay people might well fear that standard themselves.)

The unrighteousness of this new policy should be enough to prompt the courts, Congress and responsible members of Mr. Trump’s cabinet to reverse it immediately. But there is an even more compelling reason: It is extremely dangerous. Extremist groups will trumpet this order to spread the notion, today more credible than ever, that the United States is at war with Islam rather than targeting terrorists. They want nothing more than a fearful, recklessly belligerent America; so, if anything, this ban will heighten their efforts to strike at Americans, to provoke yet further overreaction from a volatile and inexperienced president.

American allies in the Middle East will reasonably question why they should cooperate with, and defer to, the United States while its top officials vilify their faith. Afghans and Iraqis supporting American military operations would be justified in reassessing the merits of taking enormous risks for a government that is bold enough to drop bombs on their homelands but too frightened to provide a haven to their most vulnerable compatriots, and perhaps to them as well. Republicans in Congress who remain quiet or tacitly supportive of the ban should recognize that history will remember them as cowards.

There may be no one better positioned to force a suspension of this policy than Mr. Trump’s secretary of defense, Jim Mattis. Mr. Mattis was clear-eyed about the dangers of a proposed Muslim ban during the election, saying that American allies were reasonably wondering if “we have lost faith in reason.” He added: “This kind of thing is causing us great damage right now, and it’s sending shock waves through this international system.”