A federal appeals court in Virginia on Thursday upheld a freeze on President Trump’s ban on immigrants from six mainly Muslim countries because it amounts to religious discrimination – a stinging defeat for the White House.

The Richmond-based 4th Circuit Court of Appeals confirmed a lower court ruling blocking the Trump administration’s revised travel ban that would have suspended immigration from six countries – Iran, Libya, Somalia, Sudan, Syria and Yemen. A showdown in the Supreme Court is likely next.

The president’s executive order “speaks with vague words of national security, but in context drips with religious intolerance, animus and discrimination,” wrote chief judge Roger Gregory.

“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 ruling said.

The 10-3 decision upheld the March ruling of a federal court in Maryland that said the ban violated the Constitution because it discriminates against Muslims.

That Maryland court in a case brought by the American Civil Liberties Union considered Trump’s heated campaign rhetoric calling for a “total and complete shutdown” of Muslims entering the country until the government could “figure out what is going on” and concluded the order issued on March 6 was discriminatory.

Trump defended his comments as necessary to protect national security.

But the court said there were “strong indications that the national security purpose is not the primary purpose for the travel ban,” the court ruled.

The ACLU praised the ruling on Thursday.

​”​President Trump’s Muslim ban violates the Constitution, as this decision strongly reaffirms,” said Omar Jadwat, director of the ACLU’s Immigrants’ Rights Project, who argued the case.

​Trump signed his initial executive order from Jan. 27 banning immigrants from seven majority Muslim countries – Iraq was included in the first version – and it sparked protests and stranded thousands of travelers at airports across the country.

A federal judge in Seattle knocked down the order saying it violated due process protections because it didn’t give travelers advance notice.

​The Trump administration then revised the order and narrowed its scope, but a federal judge in Hawaii​ on March 15 ​blocked it saying its intent was clear.

​​Judge Derrick Watson​ ​wrote that a “reasonable, objective observer” would see the order as “issued with a purpose to disfavor a particular religion, in spite of its stated, religiously neutral purpose.”​

The government is appealing the ruling to the 9th Circuit Court of Appeals in California.