No matter how many times President Donald Trump tries to rewrite his ban on travel to the United States for citizens of certain nations, he can’t change the effort’s origin: his campaign pledge to keep Muslims out of the United States. He can claim it is the product of a security review. He can add a nation that sends practically no one to the U.S. in the first place or bar a handful of people from another. But religious discrimination remains at its root.

This week a federal judge in Hawaii said as much when he struck down most of Mr. Trump’s third revision of an executive order originally issued in January that would have restricted travel to the U.S. by citizens of predominantly Muslim countries. The first two orders were both blocked by the courts on the grounds that they unlawfully discriminated against individuals based on their nationality or religion. On Tuesday, District Court Judge Derrick K. Watson concluded that Mr. Trump’s latest effort likewise “suffers from precisely the same maladies as its predecessor.” On Wednesday, a federal district judge in Maryland, Theodore D. Chuang, blocked the order’s application to anyone with a bona fide relationship with someone in the United States on the same grounds, calling the third order an “inextricable re-animation of the twice-enjoined Muslim ban.”

A ban on Muslims by any other name is still a Muslim ban because, Judge Watson wrote, “it plainly discriminates based on nationality” in a way that violates “the founding principles of this Nation.”

There was never much doubt about what the administration was trying to achieve through the president’s order. Mr. Trump made it crystal clear in 2015 that one of his first official acts as president would be to impose a “total ban” on Muslim immigration to this country. Though the White House has since tried to tone that down and reframe the issue in terms of tighter border controls and national security, it’s obvious Mr. Trump is obsessed with fulfilling that early campaign pledge, which is red meat to his base.

The president undoubtedly is betting the Supreme Court eventually will take up the matter and rule in his favor given that Justice Neil Gorsuch, a Trump appointee, now sits on the bench. But even if the high court somehow finds a way to declare the president’s actions legally justified, that won’t make them morally right. Americans have long prided themselves on living in an open society that welcomes the contributions of visitors from around the world. Shutting the door against people simply because of their religious beliefs or where they were born ought to be anathema to anyone who honors the global invitation engraved on the base of the Statue of Liberty: “Your huddled masses, yearning to breathe free, the wretched refuse of your teeming shore. Send these, the homeless, tempest tost to me, I lift my lamp beside the golden door.”

In a statement, the White House lashed out against Judge Watson’s order, saying the ban was based on an “extensive worldwide security review” by the Department of of Homeland Security, and that the court’s action “undercuts the President’s efforts to keep the American people safe and enforce minimum security for entry into the United States.” Yet Judge Watson found that the administration had failed to present any evidence of a link between a person’s nationality and the potential threat they posed. “The categorical restrictions on entire populations of men, women, and children, based upon nationality, are a poor fit for the issues regarding the sharing of public safety and terrorism-related information,” he wrote. In other words, if the goal is to keep Americans safe from terrorist attack, turning people away at the border because of their nationality or religion is one of the least effective things we can do.

Mr. Trump may never appreciate that hard truth, however. His instinct is always to blame someone else, and “Muslims” as a group are an easy target that relieves him of the obligation of thinking through the long-term consequences of his impulsive policy choices. The president’s “Muslim ban” was an absurdity from the start, and in a healthy body politic it never would have been allowed to take root in any serious national conservation about terrorism. But these are not normal times. We’re heartened by the judicial restraints the courts have so far managed to impose on the president’s power to arbitrarily determine who can and cannot legally enter the country. But we also recognize those restraints may only be temporary. The ultimate protector of American values lies in the people electing representatives who will uphold them.