A US appeals court has rejected President Donald Trump's attempt to reinstate his ban on visitors from seven mainly Muslim countries.
The 9th US Circuit Court of Appeals said it would not block a lower-court ruling that halted the order.
Mr Trump responded with an angry tweet saying national security was at risk and there would be a legal challenge.
But the 3-0 unanimous ruling said the government had not proved the terror threat justified reviving the ban.
The ruling means that people from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen with visas can continue to enter the US.
And refugees from around the world, who were also subject to a temporary ban, are no longer blocked either.
The case is now likely to end up at the highest court, the US Supreme Court.
What has the reaction been?
Mr Trump responded to the ruling by tweeting his dissent and then gave an audio statement saying it was a political decision.
The Justice Department, which made representations to the appeals court on behalf of the White House, said in a statement it was "reviewing the decision and considering its options".
Washington State Attorney General Bob Ferguson, who had sued over the ban, said it was a complete victory for the state.
New York City Mayor Bill De Blasio said: "Here in New York - the safest big city in America - we will always protect our neighbours, no matter where they came from or when they got here. Those are our values."
How did we get here?
The executive order, at the end of Mr Trump's first week in office, had sparked protests and confusion as people were stopped at US borders.
Then a week later, a federal judge in Seattle issued a temporary restraining order that stopped the ban in its tracks, after Washington state and Minnesota sued.
The Justice Department appealed to the 9th Circuit in San Francisco, which heard oral arguments this week.
Lawyers representing the US government argued that the ban was a "lawful exercise" of presidential authority.
But the two US states said the ban had harmed universities in their states and discriminated against Muslims.
The appeal judges did not rule on the constitutionality or the merits of the law, just on the question of its reinstatement.
The lower court in Seattle must still debate its merits and there are other legal challenges across the country.