(Sarah Parnass/The Washington Post)

SUCH WAS the urgency of President Trump’s temporary travel ban on citizens of seven mainly Muslim countries that he characterized its suspension by federal courts last month as a grave threat to national security. Then his administration moved rather deliberately in formulating a replacement. Three times Mr. Trump and his spokesmen announced the imminent issuance of a new order; three times they postponed it. Now, three weeks after the president first said a new order was imminent, he has signed it — a watered-down version of the original, tweaked to withstand court challenges but no less arbitrary and misguided as a means of enhancing national security.

Fortunately, federal courts had the spine to stand up to Mr. Trump’s verbal assault on the judicial system’s integrity, forcing the administration to strip some blatant excesses from the original ban, such as the exclusion of people holding valid green cards and previously issued visas. In other cases, specific cohorts of immigrants would be granted travel or visa waivers on a case-by-case basis, replacing the original order’s blanket ban. Those are significant changes.

The new order also drops Iraq from the targeted list of countries whose citizens are barred from traveling to the United States, not because the administration suddenly deemed them a diminished threat but because alienating Iraq was a grievous diplomatic and military blunder. With U.S. forces fighting alongside Iraqi troops against a common enemy, the Islamic State, it dawned on the White House that it could ill afford to antagonize a critical ally.

However, in the case of the six countries that remain on the new temporary travel blacklist — Iran, Yemen, Somalia, Sudan, Libya and Syria — the justification for their inclusion remains as flimsy as it was before.

It is still the case, as a report last month from the Department of Homeland Security reiterated, that few people from the banned countries have mounted or tried to mount terrorist attacks in the United States. It is still the case that most of those convicted or killed attempting such attacks in recent years were U.S.-born citizens. And it is still the case, as U.S. District Judge Leonie M. Brinkema found in regard to Mr. Trump’s first order, that a travel ban “may be counterproductive to its stated goal” of keeping the nation safe.

That’s because the ban, while doing virtually nothing to deter terrorist attacks in this country, aids the recruitment efforts of the Islamic State and other extremist groups by substantiating their case that anti-Islamic bigotry thrives in the United States.

At least this time, the Trump administration subjected the executive order to careful legal vetting before the president signed it. By limiting the order mainly to people with few personal connections to or roots in the United States, the administration hopes to deter fresh lawsuits by states and others arguing that the order inflicted harm on them.

The courts will decide whether the order, which renews the suspension of all refu­gee resettlement for 120 days, passes legal muster. Already clear is that it remains antithetical to American interests, values, tradition and security.