On Tuesday afternoon in San Francisco, a Justice Department lawyer argued hard that the 9th Circuit Court of Appeals should reinstate President Trump’s travel ban—or, barring that, just reinstate most of it.

It was the latest court skirmish over Trump’s most controversial move yet: an executive order banning travelers from seven majority-Muslim countries from entering the United States. And if the oral arguments that took place before the appeals court Tuesday are any indicator, it’s a legal battle that’s far from over, with stakes that are sky-high and an outcome that’s far from predetermined.

This all started late in the day on Friday, Jan. 27, when the president signed the executive order and kicked off a weekend of chaos at international airports around the country. Refugees and other travelers who had been in the air when Trump signed the order found themselves locked out of the country, and panicking lawyers rushed to major U.S. airports in hopes of helping those travelers get into the U.S.—and keeping them from signing away their rights in the process.

Immigrant and civil-rights groups went straight to court, and by the evening of Jan. 28, multiple federal judges around the country had sent down orders limiting the reach of the executive order (and, in one case, requiring that lawyers be allowed access to travelers detained at Dulles Airport—access volunteer lawyers told The Daily Beast they never got).

Next, on Feb. 3, a federal judge in Seattle put the entire executive order on ice, issuing a temporary restraining order that barred the Department of Homeland Security from enforcing it. And things in airports went back to normal—sort of, at least for a little bit.

Then came the latest legal showdown: On Feb. 7, the Justice Department, arguing for the federal government, squared off against lawyers for the states of Washington and Minnesota before a three-judge panel at the 9th Circuit Court of Appeals.

The proceedings pitted Washington State Solicitor General Noah Purcell against Justice Department lawyer August Flentje. At issue was whether the appeals court should reinstate Trump’s travel ban—a ban the White House says is necessary for national security. The ban’s many critics, including a host of former top national-security officials, say it would undermine America’s security while violating the constitutional rights of people living here.

The three judges refereed an hour of oral arguments, held over the phone and streamed live on the 9th Circuit’s website for listeners around the world. Those arguments focused on three main issues. First there were procedural questions: whether the states of Washington and Minnesota had standing to bring the federal government to court, and whether the temporary restraining order was appealable.

The arguments got a bit juicier when the focus shifted to two other questions: whether federal law bars Trump from issuing an executive order that discriminates against people based on their nationality, and whether the federal government violated anyone’s constitutional rights with the executive order.

And then there was that fallback argument the Justice Department made: that the judges should let the Department of Homeland Security enforce part of the executive order, at least for the time being.

In one particularly pointed exchange, Judge Richard Clifton grilled Flentje over just how much danger the pre-executive order immigration policies were causing.

“Is there any reason for us to think that there’s a real risk or that circumstances have changed so that there would be a real risk if existing procedures weren’t allowed to stay in place while the administration, the new administration, conducts its review?”

“Well,” Flentje answered, “the president determined that there was a real risk. That’s why the president determined that the best course was a temporary—it’s a short halt in entry for 90 days, while these procedures are looked at. And that’s understandable.”

It wasn’t immediately clear if the judges understood.

And White House spokespeople haven’t helped much to generate the perception of a real risk. On the Monday after the president signed the executive order, Sean Spicer said during the White House press briefing that the ban was not put in place in response to any intelligence indicating an immediate threat.

A few minutes after the “real risk” exchange Tuesday, Judge William Canby pressed Flentje again on the danger posed by visitors from the seven banned countries.

“In the transcript of the hearing in the district court, the district court asks the representative of the Department of Justice, ‘You’re in the Department of Justice. How many federal offenses have we had being committed by people who came in with visas from these countries?’” Canby said.

“The answer,” the judge continued, “was there haven’t been any.”

Flentje’s response sounded a touch apologetic.

“These proceedings have been moving quite fast,” he said, “and we’re doing the best we can.”

He then said some Somalis in the U.S. have been convicted of aiding the terror group al-Shabab.

“Is that in the record?” asked Judge Michelle Friedland, referring to the exhibits and documents that attorneys file when they first make their cases in district court.

“It is not in the record,” Flentje conceded. “You’re right, it’s not in the record.”

Purcell, arguing against the federal government and for Washington and Minnesota, also had his share of tough moments. One standout came when Judge Clifton pressed him on his claim that a federal statute rendered Trump’s executive order illegal.

Purcell argued that the executive order violated a statute barring the federal government from discriminating based on people’s nationalities when making decisions about issuing visas. Clifton asked if that statute only applied to people seeking immigration visas—which would exclude many of the people Trump’s executive order affected, including people on student visas. Purcell said Clifton’s point was “basically correct.”

Clifton pointed out that foreign-policy decisions discriminate based on nationality all the time. The U.S. government doesn’t treat people from France the same way it treats people from North Korea, he said.

Purcell also took heat from Clifton over whether the executive order was the realization of the Muslim ban Trump promised on the campaign trail.

“Here we’ve alleged, very plausibly and with great detail, that this was done to favor one religious group over another,” Purcell said.

“It’s not just your allegation at this stage,” Clifton replied. “So what should lead us to conclude you’ve got a likelihood of success at being able to prove the religious animus you allege?”

“For starters, that the president called for a complete ban on the entry of Muslims,” he replied.

“And is this that ban?” Clifton replied.

“No,” Purcell replied. “We’re not saying this is a complete ban on Muslims entering the country. Obviously, I mean they realize—this is, this is, well, what his adviser said on television was that he was asked for a way to, uh, implement a narrower thing that would be legal. And, uh, but, but the point is that was clearly a motivating—what, what we have alleged, and again, yes it is, we do have to show likelihood of success, but at this stage, the case file is clear, our plausible allegations are taken as true, uh, for assessing that likelihood of success.”

“Wait!” Clifton replied, his voice rising. “That cannot possibly be true. We are supposed to take your word for it, the fact that you make an allegation of the complaint, and that equals likelihood of success? You don’t really mean that, do you?”

Purcell paused.

“What I mean is that, we—we have assessed—we have alleged—”

“You can allege anything!” Clifton said. “Do I have to believe everything you allege, and say, well, that must be right? That’s not the standard.”

Then Judge Friedland jumped in, throwing Purcell a lifeline.

“You’ve actually supported these allegations with exhibits, haven’t you?” she asked.

“We have supported many of our allegations with exhibits,” he replied. “Yes, Judge Friedland, we have. And, and, I do think that’s important.”

After Purcell’s grilling concluded, Flentje made a short rebuttal. Then he urged the judges that if they wanted to keep the temporary restraining order in place, they should at least narrow it so it only applies to people who have lived in the U.S. and have connections to the country.

If the judges take Flentje up on his fallback plan, then we can expect more airport madness, as people from the banned countries making last-ditch efforts to get to the U.S. would likely get stranded in airport screening zones.

Appellate lawyers who listened to the oral arguments told The Daily Beast afterward that the fight will likely go to the Supreme Court.

Ed Grass, a retired litigation and appellate attorney who has argued cases before the 4th and 11th Circuit courts, told The Daily Beast that it was tough to game out the judges’ sympathies. Sometimes these judges ask particularly tough questions to lawyers whose cases they sympathize with, he noted, since they want to be sure they aren’t making the wrong call.

Grass went to Dulles Airport to try to help detained travelers the day after Trump signed the executive order, and he said he expected the appellate panel to send the ruling back to the district court so both parties could flesh out their arguments better.

“They’re going to say, we don’t have enough of a record to do anything right now, play some more and then come back once you have more,” Grass said. “That’s my best guess.”

If that’s what the 9th Circuit does—in a ruling expected sometime this week—then the federal government could appeal that ruling to the Supreme Court. DOJ lawyers would then argue to Justice Anthony Kennedy that he should let the federal government enforce the executive order. Should Kennedy deny them, the government lawyers could ask another Supreme Court justice to hear them out—likely Justice Clarence Thomas, viewed as most sympathetic to their case.

In the meantime, the oral arguments showed that debates about the nature of religious liberty and executive power are very much alive and well.