President Donald Trump's revised travel ban targeting six Muslim-majority countries, "speaks with vague words of national security, but in context drips with religious intolerance, animus and discrimination", a federal appeals court has in ruling against the executive order.
Trump's administration vowed to take the fight to the US Supreme Court.
In a 10-3 vote on Thursday, the US Circuit Court of Appeals for the 4th Circuit said the ban likely violates the Constitution. And it upheld a lower court ruling that blocks the Republican administration from cutting off visas for people from Iran, Libya, Somalia, Sudan, Syria and Yemen.
The Richmond, Virginia-based 4th Circuit is the first appeals court to rule on the revised travel ban unveiled in March. Trump's administration had hoped it would avoid the legal problems that the first version from January encountered.
A second appeals court, the 9th US Circuit based in San Francisco, is also weighing the revised travel ban after a federal judge in Hawaii blocked it.
The Supreme Court almost certainly would step into the case if asked. The justices almost always have the final say when a lower court strikes down a federal law or presidential action.
Trump could try to persuade the Supreme Court to allow the policy to take effect, even while the justices weigh whether to hear the case, by arguing that the court orders blocking the ban make the country less safe. If the administration does ask the court to step in, the justices' first vote could signal the court's ultimate decision.
A central question in the case before the 4th Circuit was whether courts should consider Trump's public statements about wanting to bar Muslims from entering the country as evidence that the policy was primarily motivated by the religion.
Trump's administration argued the court should not look beyond the text of the executive order, which doesn't mention religion. The countries were not chosen because they are predominantly Muslim but because they present terrorism risks, the administration said.
But Chief Judge Roger L Gregory wrote that the government's "asserted national security interest ... appears to be a post hoc, secondary justification for an executive action rooted in religious animus and intended to bar Muslims from this country."
Attorney General Jeff Sessions said the court's ruling blocks Trump's "efforts to strengthen this country's national security."
Trump is not required to admit people from "countries that sponsor or shelter terrorism until he determines that they can be properly vetted" and don't pose a security threat, Sessions said.
The three dissenting judges, all appointed by Republican presidents, said the majority was wrong to look beyond the text of the order. Calling the executive order a "modestaction", Judge Paul V Niemeyer wrote that Supreme Court precedent required the court to consider the order "on its face." Looked at that way, the executive order "is entirely without constitutional fault", he wrote.
Ilya Somin, a law professor at George Mason University, said if the Supreme Court follows a partisan divide, the Trump administration may fare better since five of the nine are Republican nominees. Still, he said, it's difficult to make a confident prediction because "Supreme Court justices don't always vote in ideological lockstep."
The first travel ban issued January 27 was aimed at seven countries and triggered chaos and protests across the country as travellers were stopped from boarding international flights and detained at airports for hours. Trump tweaked the order after the 9th US Circuit Court of Appeals refused to reinstate the ban.
The new version made it clear the 90-day ban covering those six countries doesn't apply to those who already have valid visas. It got rid of language that would give priority to religious minorities and removed Iraq from the list of banned countries.
Critics said the changes don't erase the legal problems with the ban.
The case ruled on by the 4th Circuit was originally brought in Maryland by the American Civil Liberties Union and the National Immigration Law Centre on behalf of organisations as well as people who live in the US and fear the executive order will prevent them from being reunited with family members from the banned countries.
"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. "The Constitution's prohibition on actions disfavouring or condemning any religion is a fundamental protection for all of us, and we can all be glad that the court today rejected the government's request to set that principle aside."