(BBC) A US federal appeals court has rejected President Donald Trump’s attempt to reinstate his ban on citizens from seven mainly Muslim countries.
The 9th US Circuit Court of Appeals said it would not block a ruling by a Seattle court that halted the order.
Mr Trump responded with an angry tweet saying national security was at risk and there would be a legal challenge.
It was unclear whether he intended to file an appeal to the Supreme Court or keep fighting the case in Seattle.
In its 3-0 unanimous ruling on Thursday, the appeals court 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.
However, the ruling does not affect one part of Mr Trump’s controversial executive order: a cap of 50,000 refugees to be admitted in the current fiscal year, down from the ceiling of 110,000 established under his predecessor, Barack Obama.
What did the three appeal judges say?
They accepted that the US president had sole discretion to set immigration policy but added that courts could still assess the order’s compliance with the constitution.
They discussed whether the ban violated the constitution by targeting a religious group (Muslims) but did not reach a conclusion.
The judges also found “no evidence that any alien from any of the countries named in the order” had committed a terrorist attack in the US.
However, the judges said both sides had made compelling cases: “On the one hand, the public has a powerful interest in national security and in the ability of an elected president to enact policies.
“And on the other, the public also has an interest in free flow of travel, in avoiding separation of families, and in freedom from discrimination.”
The appeal judges did not rule on the constitutionality of the order, just on the question of ending the temporary ban.
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 Attorney General Bob Ferguson, who had sued over the ban, said it was a complete victory for the north-western US 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.”
Defeated presidential challenger Hillary Clinton posted a tweet of the result:
What it all means – Anthony Zurcher, BBC News, Washington
Donald Trump’s lawyers did not make their case. In fact, according to three 9th Circuit judges, they did not even really try to make their case. Rather than explaining why the temporary travel ban was needed, the administration argued that the president’s authority on immigration was so sweeping that they did not have to explain why the order was necessary.
According to the court, the government was unable to say why Mr Trump’s ban addressed a pressing national security threat that a temporary stay of the order would worsen. The lawyers for the challenging states, on the other hand, convinced the judges that re-imposing the order at this point would create further chaos by infringing on the due process rights of those on US soil, regardless of their immigration status.
By issuing a unanimous, unsigned opinion, the judges avoid accusations of partisan bias, as one of the three was a Republican appointee.
Mr Trump tweeted a sharp “SEE YOU IN COURT” following the decision – but which court? An appeal to the Supreme Court seems likely, although a better move for the president may be to fight in the lower court until Judge Neil Gorsuch joins the top court, establishing a conservative majority on the bench.
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, the Seattle judge 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.
Other legal challenges are also under way across the country.