A federal appeals court refused to restore U.S. President Donald Trump's controversial immigration ban, delivering a blow to the White House and setting up a possible showdown in the country's highest court.

The U.S. Court of Appeals for the Ninth Circuit in San Francisco ruled on Thursday that the nationwide halt to the ban issued by a lower court on Feb. 3 can remain in place, allowing refugees and visa holders from seven Muslim-majority countries to continue entering the United States.

In a unanimous ruling, the three-judge panel said that the government had failed to explain the urgent need for the ban and had "pointed to no evidence" that citizens of the seven nations have "perpetrated a terror attack in the U.S."

Story continues below advertisement

Instead, "the government has taken the position that we must not review its decision at all," wrote the judges. "We disagree."

Shortly after the ruling was issued, Mr. Trump wrote on Twitter: "See you in court, the security of our nation is at stake!" That suggests he will ask the Supreme Court to intervene immediately.

Read more: Trump's immigration ban: What we know so far, and how it affects Canadians

Read more: How do U.S. courts work? A map of the battlefield for Trump's immigration ban

Story continues below advertisement

Read more: Trump's immigration ban is blocked: Six things you need to know

The states of Washington and Minnesota had sued the government to block the immigration ban, arguing that the measure created chaos and engaged in religious discrimination.

The Trump administration has claimed the ban is necessary in order to review vetting procedures and protect national security. However, at the appeals court hearing on Tuesday, a Justice Department lawyer was unable to cite any specific danger under questioning from the judges. "The President has determined there is a risk," stated August Flentje, the lawyer representing the government.

In sometimes stinging terms, Thursday's ruling rebutted the government's assertion that such determinations by Mr. Trump could not be challenged. While courts should give the President considerable deference in such matters, the courtesy is far from absolute, the judges wrote. Indeed, the notion that courts cannot review the lawfulness of presidential actions in matters of immigration and national security "runs contrary to the fundamental structure of our constitutional democracy."

Story continues below advertisement

Signed by Mr. Trump on Jan. 27, the immigration ban is highly contentious, triggering protests in dozens of cities across the United States as well as a chorus of criticism from technology executives, university presidents, religious leaders and Democrats.

The earlier ruling on Feb. 3 by a federal district judge in Seattle allowed visa holders from seven nations – Iran, Iraq, Syria, Yemen, Libya, Somalia and Sudan – as well as refugees to enter the United States. Mr. Trump has made clear that he sees that situation as unacceptable. He has issued a series of scathing attacks on the judiciary, which is highly unusual behaviour for a U.S. president.

On Wednesday, Mr. Trump said the courts "seem so political" and asserted that even "a bad high school student" would rule in favour of the administration. If the courts do not affirm the government's stand, he wrote on Twitter, "we can never have the safety and security to which we are entitled." Earlier he asserted that judges would be to blame in the case of future terror attacks.

The problem for Mr. Trump is that the fate of his ban now sits in the hands of judges – and his torrent of criticism makes them more likely to assert their independence. If the Trump administration asks the Supreme Court to intervene immediately, the court would hear the matter with its current complement of eight judges (the ninth seat has been empty for a year following the death of Justice Antonin Scalia and a successful Republican effort to prevent former president Barack Obama from seating a replacement).

Story continues below advertisement

Mr. Trump has nominated Judge Neil Gorsuch to the empty seat and his confirmation process is in the early stages. As part of that process, Judge Gorsuch held meetings with senators during which he distanced himself from Mr. Trump's attacks on the judiciary. Judge Gorsuch called Mr. Trump's remarks "demoralizing" and "disheartening" in a meeting with a Democratic senator, an account confirmed by one of Judge Gorsuch's advisers, according to The Washington Post.

As long as the Supreme Court has only eight members, it will represent a challenge for the Trump administration. Overturning Thursday's appeals court ruling will require the agreement of five justices. But if the court were to split along liberal-conservative lines, the result would be a 4-4 tie, which would leave the appeals court judgment intact.

In Thursday's ruling, the appeals court briefly weighed in on two elements of constitutional challenges to the ban. The judges said that the claims by Washington and Minnesota that the ban had violated the right to due process – or fair treatment through normal legal channels – were likely to succeed. Such rights apply to U.S. permanent residents travelling abroad, some of whom were affected by the ban, even though the White House later asserted it excluded them.

But the judges declined to say – for now – whether they believe the ban amounts to religious discrimination. The states of Washington and Minnesota noted that Mr. Trump had called for a ban on Muslims entering the U.S. during the presidential campaign, while a key adviser, former New York mayor Rudy Giuliani, described the immigration ban as a way to achieve the same result "legally."

Such claims raise "serious allegations and present significant constitutional questions," the judges wrote. But in light of the proceedings' sensitivity and the speed of deliberations, "we reserve consideration of these claims until the merits of this appeal have been fully briefed."