Los Angeles (AFP) – A federal appeals court on Thursday refused to restore Donald Trump’s controversial executive order closing US borders to refugees and nationals from seven Muslim-majority countries, dealing the new president a major defeat.

“We hold that the government has not shown a likelihood of success on the merits of its appeal, nor has it shown that failure to enter a stay would cause irreparable injury,” the Ninth Circuit Court of Appeals in San Francisco ruled.

The three-judge panel unanimously denied the government’s request to reinstate the measure on an emergency basis, meaning a lower court suspension of the travel ban put in place by a lower federal court stands for now.

Trump quickly reacted, defiantly vowing to pursue the battle, tweeting: “SEE YOU IN COURT, THE SECURITY OF OUR NATION IS AT STAKE!”

The court held a contentious hearing in the matter on Tuesday, with the Justice Department lawyer representing the Trump administration insisting the controversial ban was justified for national security reasons.

The order, which was issued on January 27 with no prior warning, sparked travel chaos and was met with condemnation by immigration advocacy groups.

The ban was suspended nationwide on February 3 by a federal judge in Seattle, after two US states asked it to be overturned on grounds of religious discrimination and that it had caused “irreparable injury.”

Trump’s decree summarily denied entry to all refugees for 120 days, and travelers from Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen for 90 days. Refugees from Syria were blocked indefinitely.

Top administration officials have argued it is needed to keep out Islamic State and Al-Qaeda fighters migrating from Middle East hotspots, insisting time is needed to implement stricter vetting procedures.

The court in San Francisco said aspects of the public interest favored both sides, highlighting the “massive attention” the case had drawn.

“On the one hand, the public has a powerful interest in national security and in the ability of an elected president to enact policies,” the ruling said.

“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.”

Politicians on both sides of the aisle quickly reacted, with Republicans decrying the decision and Democrats hailing it.

“Pres Trump ought to see the writing on the wall, abandon proposal, roll up his sleeves & come up w/ a real, bipartisan plan to keep us safe,” tweeted Senate Democratic minority leader Chuck Schumer.