In a Tuesday hearing over whether to reinstate President Trump’s executive order banning people from seven majority-Muslim countries and nearly all refugees from entering the US, the judges from the 9th Circuit Court of Appeals were ... skeptical.

“Are you arguing,” asked Judge Michelle Friedland, “that the president’s decision is not reviewable?”

Eventually, Department of Justice lawyer August Flentje conceded: “Uh, yes.”

It’s less extraordinary a claim than it sounds. When it comes to national security, the courts have often deferred: Judges don’t know the risks the country is facing, the argument goes, so they need to defer to the executive branch when national security is at stake.

That logic has historically given the executive branch a ton of leeway when it comes to immigration policy. When it comes to Trump’s ban, that hasn’t been the case.

Practically from the moment the executive order went into effect, federal judges have issued rulings trying to limit its effects. On Friday, federal judge James Robart in the Western District of Washington temporarily froze all enforcement of the order’s key parts: a 90-day ban on all entries to the US from people from seven majority-Muslim countries, and a 120-day ban on nearly all refugees.

The federal government is asking the Ninth Circuit to lift the freeze as quickly as possible; the Ninth Circuit’s ruling, after its Tuesday hearing, is expected in the next few days.

It’s extremely unlikely the government will succeed. At best, the court-imposed freeze will probably be in place for another week or two while Judge Robart decides whether to replace it with an indefinite injunction — an indication that the executive order isn’t likely to pass constitutional muster — or allow the ban to go back into effect.

As Robart and the Ninth Circuit work through the legal questions in the case, they’ll have to make a choice. Trump’s immigration ban may well fit the legal standard we have right now. Does that justify the ban, or does it mean the legal standard should be changed?

The first phase: deciding whether the government can appeal the temporary freeze

The order issued by Judge Robart Friday, telling the government to stop enforcing the visa and refugee bans, was a temporary restraining order — a very preliminary, short-term thing.

Such an order is designed for situations in which what the government (or whoever) wants to do would be so massive that, even if it were ultimately struck down and reversed after a full court review, the damage couldn’t be undone. Robart’s order is only in effect until he can decide whether or not to issue a preliminary injunction in the case — which might take another week or two and another round of hearings.

But the federal government doesn’t want to wait that long; it filed an emergency motion to the Ninth Circuit Court of Appeals to halt the restraining order.

So the first question the courts have to figure out — and what the Ninth Circuit is going to be ruling on — is whether to honor the government’s request, and let the ban go into effect again, or keep the freeze in place until Robart decides whether to issue a full injunction or not.

Usually, you can’t appeal a temporary restraining order. So the government has a pretty high bar to clear with its emergency motion. It argues that Robart’s ruling is an injunction disguised as a restraining order, and since injunctions can be appealed, Robart’s ruling can be too. But it’s not clear that the Ninth Circuit will be persuaded — especially when Robart plans to consider and issue the actual injunction in a matter of weeks.

It’s possible that, if it doesn’t succeed at the Ninth Circuit, the government will try to take its emergency stay request to the Supreme Court — but it’s not clear that five Supreme Court justices would be interested in hearing a stay on a temporary restraining order, even in this case. (Law professor Josh Blackman runs down the options in a blog post here.)

What’s more likely is that the executive order will remain blocked until Robart decides whether to replace the temporary restraining order with an indefinite injunction, and then that case will make its way up through the courts.

From there, if the courts defer to precedent, the Trump administration has the edge. But scholars suggest that precedent might be less important than the brazenness with which Trump’s all but daring the judiciary to rein him in.

The “plenary power”: the argument that the courts shouldn’t look too closely at the ban at all

It might seem obvious that an order that openly discriminates against people from particular countries, and that might, in practice, favor Christians and disfavor Muslims, is unconstitutional. But it actually isn’t that clear cut at all. When it comes to immigration law, the government has a lot more leeway than you might think.

For one thing, decisions about who to admit to the US involve foreign policy and national security, where there are fewer checks from the other two branches on the executive branch.

For another thing, while everyone has some rights under the Constitution, the courts have tended to agree that noncitizens have fewer than citizens do — and that people who aren’t actually in the US, but are trying to come here, don’t have many rights at all. (Exactly what rights noncitizens have is one of the things at issue in this case — the two sides disagree about how much due process the government has to provide when revoking someone’s visa, for example.)

Combine the two, and it’s easy to see why judges have been extremely unwilling to second-guess the immigration decisions of the executive and legislative branches — as Peter Spiro notes at the legal blog Lawfare, “The Supreme Court has never struck down a provision of the immigration law outright.”

The legal name for that deferential tendency is the “plenary power” doctrine.

The plenary power isn’t unlimited. But it’s very broad. And some of the provisions that the courts have allowed to stand under the plenary power doctrine would be considered totally unacceptable if they were happening in domestic policy — including treating certain immigrants differently based on the country they were coming from.

According to one plenary-power standard, as long as the government can offer a “facially legitimate and bona fide” reason for doing what it did, then it’s constitutional.

That’s the standard the Department of Justice wants the courts to use for Trump’s executive order. In the case of the executive order, the government argues, the “facially legitimate” reason for the policy is that the countries banned under the executive order had already been singled out by Congress and by the Obama administration for flaws in their visa screening process.

It’s theoretically possible that the states could argue that the executive order isn’t, in fact, “facially legitimate.” In a 2015 case about a visa denial, Justice Kennedy wrote that the “facially legitimate” standard wouldn’t apply if an applicant “plausibly alleged with sufficient particularity an affirmative showing of bad faith” on the part of the government. The states argue that, even though the government can point to a facially legitimate rationale for the country bans, they’re doing so in bad faith because the president and his advisers have made comments about banning Muslims.

If the states manage that, they’ll be doing something that has never been done before.

Even if the courts can judge the executive order, they have to decide how they’ll judge whether it’s discriminatory

Some scholars argue that the plenary power itself isn’t (or, at least, shouldn’t be) as powerful as it used to be. The big cases that have shaped it, they point out, are all decades old — and that they come from a time when discrimination was more acceptable in domestic policy as well as immigration policy.

“The Supreme Court has never upheld an immigration policy that openly discriminated on the basis of race or religion,” Prof. Adam Cox of NYU pointed out at the law blog Just Security, “during a period of constitutional history when such a policy would have been clearly unconstitutional in the domestic context.”

It’s possible that the courts will agree that this executive order is such blatant discrimination that it can’t hide behind the plenary power. But if they do, they’ll need to figure out what standard they’re using for discrimination instead.

Generally, the courts uphold laws and executive policies as long as they can find a “rational basis” for the law. In practice, this is often another easy standard for the government to meet; in Massachusetts, while issuing a ruling on Friday that declined to renew a temporary restraining order, two judges found that the government’s stated purpose for issuing the ban — to protect citizens of the US from terrorism — constituted a rational basis for issuing it.

Judge Robart appears unusually skeptical of the “rational basis” of the executive order. During oral arguments on Friday, he asked an attorney for the Justice Department whether any refugees or nationals of the seven banned countries had committed terrorist attacks in the US — and implied that, since they hadn’t, the idea that they constituted particular threats to national security didn’t count as a rational basis.

The states, meanwhile, would prefer to use a stricter standard. They argue that, because the executive order makes distinctions based on religion (in terms of prioritizing “religious minorities” for refugee resettlement), the executive order deserves strict scrutiny — the highest standard. That would make it a lot easier for the courts to strike down the executive order — but because of the unique deference given to immigration law, getting courts to apply strict scrutiny could be a tough sell.

The states’ plan B: even if the order isn’t unconstitutional, it might still be illegal

Even if the government manages to set a low bar for constitutional review, it still might not be able to reinstitute the ban. That’s because in addition to the constitutional challenge, the states argue that the executive order violates a whole passel of laws — including, most notably, the very law the Trump administration cites to justify the ban.

The Immigration and Nationality Act gives the president the authority to ban any “alien or class of aliens” from entering the US. But it also prohibits the executive branch from discriminating against someone applying for a visa “because of the person’s race, sex, nationality, place of birth, or place of residence.”

Critics of Trump’s executive order, including the states suing in this case, maintain that the nondiscrimination provision prevents Trump from banning a “class” of aliens if that class is a nationality or place of birth — as the executive order appears to do to people from the seven banned countries.

The federal government argues that the ban provision trumps the nondiscrimination provision, and that previous presidents have done basically the same thing Trump is doing in banning aliens based on nationality. The states argue that the nondiscrimination provision trumps the ban provision (and point out that the precedents for bans based on nationality aren’t nearly as broad as the one Trump just issued).

For the moment, it’s another issue where there are more questions than answers. But it’s one to look out for, since it offers the courts a way to decide the issue without getting to the tricky interplay of constitutional rights and national security.

The Trump administration is testing the limits of judicial patience

Legally, these questions are independent. But the answers to them might rely on a more fundamental question: Does the federal judiciary trust the Trump administration when it says the order is necessary to keep Americans safe?

“To rule against the government here, the Ninth Circuit, and ultimately the Supreme Court, will have to hold that the Executive Order is premised on ‘alternative facts,’” Blackman writes. “This is not something any court (to my knowledge at least) has ever done.”

It’s almost as if Trump is trying to poke the judiciary into action. As Jack Goldsmith wrote at Lawfare, he might be his own worst enemy:

Judges in the short term will be influenced by the reaction to the EO Immigration order, and by doubts about executive process, integrity, truthfulness, and motivation that the manner of its issuance implies. They will also worry a lot about being perceived to cave to executive pressure. The pressure from Trump, and related events, thus make it more likely—much more likely, in my view—that the Ninth Circuit and, if it comes to it, the Supreme Court will invalidate the EO in some fashion.

If the Trump administration were on shakier legal ground to begin with, this would barely even be a question. But it’s not. The executive branch’s immigration powers are pretty damn broad. The Trump administration is, however, apparently testing the limits of judicial patience. And between the chaotic rollout and the presidential taunting, that patience may snap.