Alan Gomez, and Richard Wolf

USA TODAY

A federal appeals court in Richmond delivered yet another blow Thursday against President Trump's effort to institute a travel ban targeting six majority-Muslim countries, making a final Supreme Court showdown more likely.

The full U.S. Court of Appeals for the 4th Circuit ruled 10-3 to uphold a lower court's decision that barred the Trump administration from implementing its second attempt at the travel ban. The decision continued a trend among federal courts from coast to coast.

Chief Judge Roger Gregory said revisions removing any mention of religion from the second executive order did not hide the real motive: "President Trump’s desire to exclude Muslims from the United States."

“From the highest elected office in the nation has come an executive order steeped in animus and directed at a single religious group,” he said in the 79-page opinion.

All 10 judges in the majority were named to the court by Democratic presidents, though Gregory was re-nominated by George W. Bush. The three dissenters were named by Republicans.

Attorney General Jeff Sessions vowed that the case would be appealed to the Supreme Court because it "blocks the president's efforts to strengthen this country's national security."

"As the dissenting justices explained, the executive order is a constitutional exercise of the president's duty to protect our communities from terrorism," he said.

But the court debunked the administration's claim that the ban was aimed at protecting national security as a "secondary justification for an executive order rooted in religious animus and intended to bar Muslims from this country."

The scathing opinion consistently referenced Trump's own words on the campaign trail and after his election, quoting amply from media reports, which it said made clear his true intention. It ruled that the executive order could never "survive any measure of constitutional review."

"Surely the Establishment Clause of the First Amendment yet stands as an untiring sentinel for the protection of one of our most cherished founding principles — that government shall not establish any religious orthodoxy, or favor or disfavor one religion over another," Gregory wrote for the majority.

"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."

The White House has said the temporary ban is needed to improve vetting procedures so that terrorists do not enter the United States as travelers or refugees. Justice Department lawyers argued in court that statements made during a political campaign should not factor into actions taken by an elected official.

Changes made to the revised ban included exempting thousands of foreign nationals who hold valid visas or green cards. It eliminated Iraq from the original list of affected countries, leaving Iran, Libya, Somalia, Sudan, Syria and Yemen. It contained no preference for religious minorities, while the original had favored Christians. And it included a waiver process for those claiming undue hardship.

Still, some judges questioned whether the government established enough of a national security threat to warrant a blanket ban against people from the six targeted countries. Judge Barbara Milano Keenan said Trump needed to show more than “vague uncertainty” about people coming from those countries to deem all 180 million residents as national security risks.

Acting Solicitor General Jeffrey Wall told the judges during oral argument earlier this month that it was not their job to psychoanalyze a president. Wall argued that candidates' statements in the midst of a contentious campaign are irrelevant, and that scrutinizing them after the fact would chill political debate in future campaigns.

In his ruling, Gregory wrote that campaign comments absolutely matter. The executive order "cannot be divorced from the cohesive narrative linking it to the animus that inspired it," he wrote. "We find that the reasonable observer would likely conclude that (the order's) primary purpose is to exclude persons from the United States on the basis of their religious beliefs."

"To the extent that our review chills campaign promises to condemn and exclude entire religious groups, we think that a welcome restraint," he wrote.

Read more:

Will Supreme Court rescue Trump's immigration travel ban?

Trump slams federal judge's freeze on second travel ban

Refugee admissions plummet under Trump, USA TODAY analysis finds

In a dissenting opinion signed by three judges, Judge Paul Niemeyer wrote that the district court and his colleagues in the majority ignored long-held court precedents when they decided that candidate Trump’s campaign statements could be used against him as president.

Niemeyer said there were more than enough reasons for a president to institute the “modest action” of temporarily suspending immigration from the targeted countries, given their ties to terrorism.

"The plaintiffs conceded during oral argument that if another candidate had won the presidential election in November 2016 and thereafter entered this same executive order, they would have had no problem with the order,” he said.

Critics who have called Trump's revised travel ban "Muslim Ban 2.0," based on his campaign pledge to stop Muslim immigration into the U.S., celebrated Thursday's ruling.

"Over and over we are seeing the courts and the public soundly reject this blatant attempt to write bigotry into law," said Margaret Huang, executive director of Amnesty International USA. "Rather then wait for yet another court to rule against it, Congress can and must take action that will end this discriminatory and dangerous policy once and for all."

A ruling is expected any day in a similar case from a three-judge panel of the U.S. Court of Appeals for the 9th Circuit, based in San Francisco.

At issue is Trump's plan to ban most travel from six countries — Iran, Libya, Somalia, Sudan, Syria and Yemen — for 90 days and suspend the entire refugee program for 120 days.

Trump first tried to implement the travel ban by signing an executive order on Jan. 27. That order was in effect for seven days before it was blocked by a federal judge in Seattle, a ruling upheld by the 9th Circuit.

Rather than appeal to the Supreme Court, Trump revoked his first travel ban and issued a revised version on March 6. That order was blocked by a federal judge in Hawaii hours before it went into effect, as well as another judge in Maryland. The Justice Department appealed both rulings.

Now that the administration has lost in the 4th Circuit, the Justice Department could appeal to the Supreme Court. The high court, now at full strength with the addition of Trump's nominee, conservative Justice Neil Gorsuch, has divided in the past on immigration issues. Those 4-4 ties, which were commonplace following the death of Justice Antonin Scalia, could tilt in Trump's favor with Gorsuch on the bench.