A federal appeals court upheld a block on President Trump’s travel limits Thursday, ruling that while the president’s policy was cloaked in national security concerns, it “drips with religious intolerance, animus, and discrimination” toward Muslims.

Attorney General Jeff Sessions quickly vowed to appeal to the Supreme Court, saying judges are interfering with the president’s national security powers.

But for now the ruling maintains a national injunction preventing the Homeland Security Department from denying admission to visitors from six majority-Muslim countries.

“Congress granted the President broad power to deny entry to aliens, but that power is not absolute. It cannot go unchecked when, as here, the President wields it through an executive edict that stands to cause irreparable harm to individuals across this nation,” Chief Judge Roger L. Gregory said in the controlling opinion for the 4th U.S. Circuit Court of Appeals.

Judge Gregory faulted Mr. Trump’s motives in drawing up the March 6 executive order, citing back to when candidate Trump first proposed a ban on Muslim entry to the U.S. in December 2015, in a statement posted to the campaign website.

The judge drew a chain between those comments and Mr. Trump’s words and actions as president — including the fact that the statement was still on the website until May 8, just before the court’s oral arguments.

That, Judge Gregory said, bespeaks a continuing “religious animus” that runs afoul of the First Amendment.

The ruling marks the first time that an appeals court has ruled on Mr. Trump’s revised order, and analysts said it was a serious defeat for the president.

Six other judges signed onto Judge Gregory’s opinion, while three more concurred in separate opinions. Three judges dissented, saying Mr. Trump’s order was lawful and warning against using campaign statements to indict a president’s actions.

“Opening the door to the use of campaign statements to inform the text of later executive orders has no rational limit,” wrote Judge Paul Niemeyer, who said it was senseless to lock presidents into statements that are often ambiguous and can be changed or developed over time.

The ideological divisions on the court were clear: All 10 of the judges who upheld the injunction were nominated by Democrats, including Judge Gregory, who was first nominated by President Clinton and renominated by President George W. Bush. The three judges who dissented were all appointed by Republican presidents.

Mr. Trump initially sought a 90-day halt in almost all entries for people from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen. That first executive order, issued in January, was blocked by courts, and he returned with a new order he said was written to accommodate the judges’ concerns.

The new order, issued in March, dropped Iraq from the list after that country promised better cooperation and vetting of travelers, and narrowed the travel ban so it didn’t apply to those who could show that they had some ties to the U.S.

Groups representing immigrants and refugees, including the International Refugee Assistance Project and the American Civil Liberties Union, challenged Mr. Trump’s revised executive order arguing that it was too similar to the first and was a form of religious discrimination.

The 4th Circuit agreed, ruling that the same animus Mr. Trump and some of his spokesmen showed toward Muslims during the campaign and that tainted the first order also tainted the second version, which it dubbed “EO-2.”

“EO-2 cannot be divorced from the cohesive narrative linking it to the animus that inspired it. In light of this, we find that the reasonable observer would likely conclude that EO-2’s primary purpose is to exclude persons from the United States on the basis of their religious beliefs,” Judge Gregory wrote.

The court’s majority accepted the judgment of former top Clinton, Bush and Obama administration officials — including Cabinet secretaries, CIA chiefs and top diplomats — who said in an amicus brief that there was no legitimate national security reason to block travel from the six targeted countries.

Trump administration officials heatedly disputed that claim, pointing out that it was the Obama administration and Congress that first identified the countries as danger spots.

Writing in dissent, Judge Dennis W. Shedd said the court’s ruling was dangerous.

“Regrettably, at the end of the day, the real losers in this case are the millions of individual Americans whose security is threatened on a daily basis by those who seek to do us harm,” the judge wrote.

The White House concurred.

“These clearly are very dangerous times, and we need every available tool at our disposal to prevent terrorists from entering the United States and committing acts of bloodshed and violence,” said spokesman Michael Short.

Judge Niemeyer, in his dissent, said the majority’s attempt to evaluate presidential actions based on campaign statements “is fraught with danger and impracticability.”

“If a court, dredging through the myriad remarks of a campaign, fails to find material to produce the desired outcome, what stops it from probing deeper to find statements from a previous campaign, or from a previous business conference, or from college?” Judge Niemeyer wrote.

He said the majority ruling tossed aside Supreme Court guidance on when to look behind a government action for evidence that the action was taken in bad faith.

Josh Blackman, an associate professor at the South Texas College of Law, said the dissenters’ complaints about handling of precedent are the kinds of things that could compel the Supreme Court to take the case.

“The court of appeals leapt over a lot of precedent to get where they did,” Mr. Blackman said. “There are holes in the opinion. The court will want to patch those holes.”

Mr. Sessions said he will give the Supreme Court a chance to hear the case.

“The president is not required to admit people from countries that sponsor or shelter terrorism, until he determines that they can be properly vetted and do not pose a security risk to the United States,” the attorney general said. “This Department of Justice will continue to vigorously defend the power and duty of the Executive Branch to protect the people of this country from danger and will seek review of this case in the United States Supreme Court.”

The 4th Circuit on Thursday did vacate part of the Maryland district court’s ruling, saying the lower court judge had gone too far by including Mr. Trump himself in the blockade.

“We therefore lift the injunction as to the President only. The court’s preliminary injunction shall otherwise remain fully intact,” Judge Gregory ordered.

Omar Jadwat, an attorney with the American Civil Liberties Union who argued the case, said he didn’t expect that to have any practical effect.

“From our perspective, it’s a complete win because in all practical terms the injunction is continuing in full force,” he said.

The Maryland court enjoined only Mr. Trump’s travel ban on the six majority-Muslim counties. It did not block his plan for a 120-day halt in refugee admissions.

A court in Hawaii has issued an injunction preventing the administration from following through on that part of Mr. Trump’s revised order. The 9th U.S. Circuit Court of Appeals heard arguments in that case this month but has yet to issue a ruling.

Sign up for Daily Newsletters Manage Newsletters

Copyright © 2020 The Washington Times, LLC. Click here for reprint permission.