Richard Wolf, and Alan Gomez

USA TODAY

A federal appeals court Thursday refused to let President Trump reinstitute a temporary ban on travelers from seven majority-Muslim nations, ruling that it violates the due process rights of people affected without a sufficient national security justification.

The unanimous verdict quoted a 75-year-old Supreme Court precedent that said courts have a duty “in time of war as well as in time of peace, to preserve unimpaired the constitutional safeguards of civil liberty.”

The quick decision from a three-judge panel of the U.S. Court of Appeals for the 9th Circuit could lead to a showdown at the Supreme Court within days, unless the administration dials back the travel ban or agrees to try its case before the federal judge in Seattle who ordered it blocked last week.

The Justice Department said it was "reviewing the decision and considering its options." But Trump clearly indicated more appeals are coming.

"SEE YOU IN COURT, THE SECURITY OF OUR NATION IS AT STAKE!" he tweeted minutes after the ruling was released.

Washington Gov. Jay Inslee responded, "Mr. President, we just saw you in court and we beat you."

The 29-page order represented a wide-ranging rebuke of Trump's travel ban. The judges found that the plaintiffs in the case -- the states of Washington and Minnesota -- showed that the ban may have violated the due process rights of foreigners who had valid visas and green cards, as well as those in the country illegally.

They also said "serious allegations" about religious discrimination against Muslims raised "significant constitutional questions" requiring a full airing in a trial court.

And the order also rejected a last-minute suggestion by the Justice Department to scale back the ban so that it would apply only to visa holders who had never stepped foot in the U.S. "It is not our role to try, in effect, to rewrite the executive order," they wrote.

The panel said that the president should get "considerable deference" in the areas of immigration and national security, "it is beyond question that the federal judiciary retains the authority to adjudicate constitutional challenges to executive action."

Washington state Solicitor General Noah Purcell, who tried the states' case during Tuesday's oral arguments, said the court "seriously considered all the government's arguments and rejected them."

The ACLU, which has led several lawsuits challenging Trump's order, said they will continue fighting the "Muslim ban" every step of the way. "The government's erratic and chaotic attempts to enforce this unconstitutional ban have taken a tremendous toll on innocent individuals, our country's values, and our standing in the world," said Omar Jadwat, director of the ACLU’s Immigrants’ Rights Project.

Trump's ban, announced Jan. 27, temporarily barred citizens of Iraq, Iran, Libya, Somalia, Sudan and Yemen for 90 days, all refugees for 120 days, and Syrian citizens indefinitely. It led to chaos at U.S. and international airports as tens of thousands of visa holders were blocked from entering the country or detained after arriving in the U.S.

A barrage of protests and lawsuits followed, leading to federal court rulings against the ban in New York, Virginia and elsewhere. One judge in Massachusetts later ruled in Trump's favor, but on Friday, District Judge James Robart in Seattle halted the policy nationwide, citing "immediate and irreparable injury" to foreigners with valid visas and green cards.

Read more:

Federal appeals court skeptical of Trump's travel ban

Trump's travel ban court hearing: Five takeaways

Trump's travel ban: A clash of conflicting laws

The next day, the State Department said it would restore more than 60,000 canceled visas, and the Department of Homeland Security stopped enforcing the ban, reverting to standard inspections. Trump denounced the ruling of the "so-called judge" in starkly personal terms, and the Justice Department appealed to the 9th Circuit, the nation's most liberal appeals court with jurisdiction over western states.

That court initially refused to lift Robart's restraining order Saturday, required both sides to submit legal arguments by Monday, and held an extraordinary, hour-long telephone hearing Tuesday that was live-streamed to listeners around the world. All three judges voiced skepticism about the need for the ban, but one said it did not appear to target Muslims in general.

The Trump administration contends that the president has authority under the Constitution and congressional statute to control immigration for national security purposes. They point to a 1952 law that allows a president to bar entry to immigrants or classes of immigrants if the president deems them to be "detrimental to the interests of the United States."

As a fallback, the Justice Department's August Flentje suggested on Tuesday that the president's executive order could be scaled back to allow immigrants from the affected countries who have already spent time in the U.S. to continue traveling without restrictions. The ban would still apply to visa holders from the affected countries who have not yet entered the U.S.

Opponents of the travel ban, led by Washington state and Minnesota and including nearly 20 other states, former national security officials and leading technology companies, say the ban discriminates against citizens of certain countries and the Muslim religion. They point to a 1965 law that prohibits discrimination against immigrants based on their country of origin, and claim the ban violates the establishment clause of the Constitution that protects freedom of religion.

Purcell, argued Tuesday that students were stranded, families separated and longtime U.S. residents blocked from traveling abroad for fear of being stranded overseas.

While the judges mulled and crafted their ruling, Trump renewed his verbal assault on the judiciary. He called the oral arguments at the 9th Circuit "disgraceful," complained that courts "can be so political" and warned, "Right now, we are at risk because of what's happened."

His comments even drew a generalized response from his Supreme Court nominee, Judge Neil Gorsuch of the U.S. Court of Appeals for the 10th Circuit, who called such remarks "disheartening" and "demoralizing" in a private meeting with a Democratic senator. After Gorsuch's reaction became public, Trump said it had been distorted.