SAN FRANCISCO — In a major defeat for President Donald Trump’s new administration, the 9th Circuit Court of Appeals on Thursday ruled that his controversial travel ban will remain suspended.

For now, refugees and citizens from Iraq, Syria, Iran, Libya, Somalia, Sudan and Yemen can continue to travel to the U.S., but it remains unclear how long that reprieve will last. The administration is expected to appeal the decision to the Supreme Court.

The unanimous ruling by a panel of three appellate judges, over a ban that has sparked nationwide backlash and caused chaos at airports where visa-holders were detained upon arrival, raised serious concerns about the legality of the administration’s executive order. The judges also delved into the broader question of Trump’s authority as president, taking issue with his position that some of his actions as head of the executive branch are above judicial review.

“The Government has pointed to no evidence that any alien from any of the countries named in the Order has perpetrated a terrorist attack in the United States,” the judges wrote. “Rather than present evidence to explain the need for the Executive Order, the Government has taken the position that we must not review its decision at all. We disagree.”

Thursday’s decision is the first appellate court ruling on the president’s travel ban, coming in the most sweeping case of the numerous challenges that have been made around the country.

Trump quickly took to Twitter to respond to the ruling with a challenge: “SEE YOU IN COURT, THE SECURITY OF OUR NATION IS AT STAKE!”

SEE YOU IN COURT, THE SECURITY OF OUR NATION IS AT STAKE! — Donald J. Trump (@realDonaldTrump) February 9, 2017

Washington Attorney General Robert Ferguson, who brought the lawsuit challenging the executive order, seemed unimpressed with the threat.

“We have seen him in court twice, and we’re two for two,” he said during a news conference Thursday, when asked to respond to the president’s tweet. “And in my view, the future of the constitution is at stake.”

The Department of Justice had a more subdued response than the president.

“The Justice Department is reviewing the decision and considering its options,” a spokeswoman wrote in an emailed statement.

A Seattle judge put Trump’s executive order on hold last Friday, prompting a quick appeal from the administration. On Tuesday, the 9th Circuit grilled the lawyers on both sides, asking tough questions during oral arguments held via telephone and live-streamed on the court’s website.

The administration had argued Trump’s executive order could not be challenged in court.

“The Government has taken the position that the President’s decisions about immigration policy, particularly when motivated by national security concerns, are unreviewable, even if those actions potentially contravene constitutional rights and protections,” the judges wrote in the 29-page ruling. “There is no precedent to support this claimed unreviewability, which runs contrary to the fundamental structure of our constitutional democracy.”

The court also found the government failed to demonstrate that the executive order granted appropriate protections to immigrants. The order denied them notice or a hearing before restricting their ability to travel, and failed to grant permanent residents who leave the country a sufficient way to challenge the government if they are denied re-entry.

Trump’s administration had argued most of the travelers affected by the ban are not U.S. citizens and have no right to such protections. But the court found such protections apply to everyone within the United States, including aliens.

Shortly after the ban started, the administration said it would not apply to lawful permanent residents. But the court found it could not rely on that assertion, citing “the government’s shifting interpretations of the Executive Order.”

Emphasizing that their analysis was preliminary, the judges declined to say whether the travel ban discriminates against Muslims, as the plaintiffs alleged. But the judges did suggest prior statements Trump made about his intent to implement a “Muslim ban” could be used against him here.

“The States’ claims raise serious allegations and present significant constitutional questions,” the judges wrote. “We reserve consideration of these claims until the merits of this appeal have been fully briefed.”

Thursday’s ruling only determined the immediate fate of the travel ban. The issue will return to federal court for a more sweeping analysis.

The court’s order suggested the judges’ minds could be changed on some issues if the government came up with stronger evidence supporting the immigration ban, said Rex Heinke, a Los Angeles-based appellate attorney whose firm filed a brief in the case on behalf of the Fred Korematsu Center for Law and Equality, an anti-discrimination advocacy group.

“They essentially, it seems to me, invited the government to come in with any evidence it has to show that the executive order does anything to prevent terrorism in the United States,” he said.

Heinke said it’s unlikely the administration could win on this issue in the Supreme Court. The vote could end up in a 4-4 tie, due to a vacancy left by Justice Antonin Scalia’s death last year. If that occurs, the 9th Circuit’s ruling will stand.

California Attorney General Xavier Becerra, who filed a brief in the case opposing the immigration ban, praised Thursday’s ruling.

​”The Trump ​administration violated the Constitution when it blocked tens of thousands of law-abiding people — who have already been vetted and received permission to enter — from traveling to the United States,” he wrote in a statement Thursday. “As this issue moves further through the courts, I will take every measure possible to inform Californians of their rights and to monitor the federal authorities’ adherence to the suspension of the Administration’s un-American and unconstitutional order.”

Staff writer Katy Murphy contributed to this report.