On Thursday, a federal appeals court refused to reinstate President Trump’s executive order temporarily banning travel into the United States by all refugees and everyone from seven predominantly Muslim countries. In the biggest legal blow yet to the new administration, a three-judge panel of the 9th U.S. Circuit Court of Appeals ruled unanimously to uphold a temporary restraining order against the ban.

But the case will continue to wend its way through the judicial system. Minutes after losing in court, Trump tweeted:

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

But see whom? In what court? And when?

How did we get here?

The case, Washington v. Trump, began in late January when the state of Washington filed a complaint against the president, seeking to invalidate parts of his executive order. Soon after, Minnesota joined in. The District Court for the Western District of Washington, a federal trial court, granted those states a temporary restraining order, blocking the White House from enforcing parts of its executive order.

The Trump administration appealed that order up to the 9th Circuit, which covers Washington and a handful of other Western states, and lies just one notch below the Supreme Court. The 9th Circuit heard arguments in the case on Tuesday, and issued its ruling for Washington and Minnesota — and against Trump — on Thursday.

What does the 9th Circuit’s ruling say?

The 29-page order received wide praise from legal experts and journalists online Thursday night, who called it “impressive,” “thorough,” “careful” and “coherent” — especially given that the court took only two days to turn it around. It is “hard to imagine more than one or two members of SCOTUS disagreeing” with it, wrote Steven Mazie, a Supreme Court writer for The Economist.

The court held that “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.” And, despite Trump’s recent Twitter attacks on the judicial branch, the ruling read that “it is beyond question that the federal judiciary retains the authority to adjudicate constitutional challenges to executive action.”

The opinion is “a complete and total repudiation of the Trump administration’s legal position in this case,” Jeffrey Toobin, the legal correspondent for The New Yorker, said on CNN.

The 9th Circuit is known as a liberal court, but there was an element of bipartisanship to Thursday’s opinion: The three federal judges on the panel were appointed by Jimmy Carter, George W. Bush and Barack Obama.

What comes next?

The Supreme Court, eventually.

There are three paths the case could take on its way there, according to Josh Blackman, a law professor at South Texas College of Law. First, the Trump administration could file an emergency application with the Supreme Court, once again seeking a stay of the restraining order. That process could move quite quickly. The New York Times reported that that was the most likely course of action and that a decision as soon as next week is possible.

Second, the White House could file an emergency petition and petition for certiorari — the slower, more traditional path to the Supreme Court. This has an added benefit for the Trump administration: By the time the case was heard by the court, Trump’s nominee Neil Gorsuch could have a seat on the bench.

Third, they could bide their time with respect to the Supreme Court. They could simply let the case play out in the lower district court in Seattle — the judge there still has to decide on issues beyond the temporary restraining order. Or they could petition the full 9th Circuit en banc — 11 judges as opposed to just the three-judge panel.

So the Trump administration has a decision to make. It can try to rush the case to the top of the judicial food chain as fast as it can or play it more coolly. On Thursday night, #AppellateTwitter seemed to think that #AppellateTwitter was predicting the latter.

Another important note is the timing of the executive order itself. Aspects of it, as signed by the president late last month, are only valid for 90 days, and may expire before some of these legal scenarios play out. Yet another option for the White House would be to pause, redraft a more permanent order, and deal with its legal fallout later on.

Trump’s press secretary, Sean Spicer, was asked in a bizarre Breitbart interview Thursday night whether this case would wind up at the Supreme Court. “I think we’re going to have to examine our legal options, that’s what our counsel’s office is doing now, to make sure that we know what the best legal route to do is,” he said.

Whether it’s this case or another — and there are others — one is almost certainly destined for Chief Justice John Roberts and company. “It is clear, I think, that the Supreme Court is going to have to address this sooner rather than later,” Toobin said.

Would Trump prevail at the Supreme Court?

Without Gorsuch, maybe not. With Gorsuch, eh, maybe? (Predicting the Supreme Court can be a fool’s errand.) Trump certainly expressed confidence. But the 9th Circuit judges wrote that “the government has not shown a likelihood of success on the merits of its appeal.”

More broadly, and something to keep in mind beyond just this case, is that presidents have been losing more and more at the Supreme Court. FiveThirtyEight charted Obama’s record-low winning percentage, back in 2015. And more recently, scholars Lee Epstein and Eric Posner re-examined the issue, finding a broad downward trend in presidents’ success at the high court. Administrations used to win regularly more than two-thirds of their cases, but that number has dipped to below one-half in recent years.

Also of note, however: The 9th Circuit often holds the dubious distinction of being the circuit whose decisions are most often reversed by the Supreme Court.

Arguing the case on behalf of the White House before the Supreme Court would be Trump’s acting solicitor general, Noel Francisco. Francisco has argued three cases at the high court, winning twice. But Politico has reported that George Conway, a New York lawyer and Kellyanne Conway’s husband, may be the front-runner for the solicitor general nod. And he may soon become a busy man.

What if there’s a 4-4 tie?

The court is still shorthanded at eight justices — four were appointed by Democratic presidents, and four by Republicans. A 4-4 decision would affirm the ruling of the lower court — continuing to freeze Trump’s executive order, in this case — but would not create a national precedent, as a typical Supreme Court decision would. Gorsuch, a potential tiebreaker, is waiting in the wings. But if history is any guide, he won’t take his seat until mid-March at the soonest.