“Make this one out of cast-iron,” the late Judge John Butzner said to me one day in chambers. “There are going to be a lot of weasels sniffing around it.”

I was Butzner’s clerk. He was assigning me to draft an opinion in a case on an abstruse point of federal law. No court had ever decided this particular question—and a lot of money was riding on the answer. Some judges on the Fourth Circuit would object to the result his panel had reached. Once Butzner’s opinion was published, they might try to persuade the other judges to rehear the case “en banc”—meaning on a bench including all members of the Circuit.

It was a high-stress assignment, even though he gave me all the time I needed.

Imagine the atmosphere in chambers this week as three Ninth Circuit judges and their clerks worked frantically to produce an opinion in Washington v. Trumpthe case testing the constitutionality of President Trump’s executive orderbanning refugees from around the  world, and all visitors from seven predominantly Muslim countries.

They had 48 hours. And they could hear sniffing at the door.

The opinion is written with remarkable care. Even though it is strictly preliminary, one of the criteria the court applies at this stage is called “likelihood of success on the merits.” In other words, if the court thought the government would win on the underlying issues, it would have reinstated the travel ban.

It didn’t. And the panel didn’t seem impressed with the government’s case on the merits. The members—Judges William C. Canby, Richard Clifton, and Michelle Friedland—include two Democratic appointees and one Republican. But they were unanimous and firm. The Administration could have suffered a greater setback at this stage, but it’s hard to see how.

Some federal courts experts had speculated that the panel might dodge the underlying issue of the travel ban. They could have done that by dismissing the government’s emergency motion for a stay as untimely. It is hornbook law that a “temporary restraining order,” like the one issued by District Judge James L. Robart in this case, is not subject to appeal. That rule applies unless the TRO is in substance actually a “preliminary injunction”—meaning a longer-lasting order freezing the situation in place. If the panel had dismissed the appeal on those grounds, it would have sent the case back to the federal District Court, leaving Judge Robart out on a limb by himself.

Instead, the panel found that the TRO, because it was going to last longer than 14 days, really was a preliminary injunction. Thus they could  hear the government’s appeal.

Then the benchslapping began.

The opinion mows down the government’s argument down one by one. I am not sure it ignores a single claim the administration made—and the panel not only disagreed with each of them, it showed polite disdain for most.

The panel begins with the government’s claim that the executive order is “unreviewable.” The President’s statutory discretion to exclude “any class of aliens” is absolute, the government said. That claim “runs contrary to the fundamental structure of our constitutional democracy,” the panel responded. Courts often defer to the executive in national security and immigration matters, but “neither the Supreme Court nor our court has ever held that courts lack the authority to review executive action in these arenas for compliance with the Constitution.”

The court then cited numerous cases supporting that principle—pointedly including even the notorious Japanese Internment cases of World War II and the equally disreputable Chinese Exclusion cases of the 1800s. It concluded (in a deadpan quote from an earlier case) that executive judgments “do not automatically trump the Court’s own obligation to secure the protection that the Constitution grants to individuals.”

After the order was announced, the government backtracked on its scope. It did not apply to lawful permanent residents who have been living in the U.S. but were temporarily abroad, the White House counsel’s office announced. (Originally the Department of Homeland Security had said it did.) The court refused to consider this new interpretation, because,  “in light of the government’s shifting interpretations of the Executive Order, we cannot say that the current interpretation by the  White House ... will persist past the immediate stage of these proceedings.”

It’s a politer way of saying what Justice Sonia Sotomayor once said to a lawyer during oral argument: “Nothing you say or read to me am I going to believe.”

Next came the issue of whether the order complies with the Fifth Amendment’s Due Process Clause. The government argued that most non-citizens covered by the order have no due process rights to enter or remain in the country. The court kicked that one to the curb. Aliens in the U.S.—even undocumented ones—“continue to have potential claims regarding possible due process rights. So do temporary visa holders who might want to travel abroad.” As for those who are applying for visas but have not come here, the government’s treatment of them may implicate “a relationship with a U.S. resident or an institution that might have rights of its own to assert.” That’s an ominous sign for the government; once the due process rights are tethered to a person or institution already in the U.S., they will be harder to dislodge.

Then the court turned to the heart of the constitutional claim—that the order “was intended to disfavor Muslims,” thus violating the equal protection principle of the Fifth Amendment. After oral argument, some thought that at least Judge Clifton might buy the argument that the EO is not a “Muslim ban.” That’s because it doesn’t use the term “Muslim,” and the full visa ban applies only to seven countries. Though those countries are predominantly Muslim, there are a lot of Muslims in the world it doesn’t cover.

Countering that, of course, are the dozens of proud statements by candidate Trump and his surrogates that he was planning “a total and complete shutdown of Muslims entering the United States” and even that the current EO was a carefully disguised way of doing exactly that. At oral argument, August Flenje, the government lawyer, dismissed these quotes as “some newspaper articles.” Judge Clifton responded angrily, “"Do you deny the statements that then-candidate Trump and his political adviser, Mr. Giuliani — do you deny those statements were made?"

“No,” Flentje said.

In its opinion, the panel said, “It is well established that evidence of [discriminatory] purpose beyond the face of the challenged law may be considered in evaluating Establishment and Equal Protection claims.”

The statements, as Judge Bradley of Law & Order might say, are in. Though the court did not decide the equal protection issue, consideration of that wording may make the government’s case much harder.

Finally, the panel told the government that it had failed to produce “any evidence” of “an urgent need for the executive order to be immediately reinstated.” The government argued that Trump may have secret information he has not shared; okay, the court responded, show us. “Courts regularly receive classified information under seal and maintain its confidentiality.”

The panel did throw the government one bone: “Aspects of the public interest favor both sides.” National security is important, it said. But, it added pointedly, so is “the free flow of travel, ... avoiding separation of families, and ... freedom from discrimination.” The government hadn’t shown evidence to tilt the scales its way.

The government could now ask the full Ninth Circuit to vacate the panel ruling and rehear the case in front of a larger panel; or it could run to the Supreme Court and ask it to reinstate the travel ban.

That’s where cast-iron comes into it. The opinion is well crafted, measured in tone, and grounded in caselaw. A judge on the fence might hesitate to brush it aside.

That’s especially true because the President has made life hell for his lawyers. He attacked Judge Robart as a “so called judge.” He attacked the panel, even before the decision, as “so political.” He warned that he will blame “the court system” if “something happens” while his order is stayed.

At 8:15 Friday morning, he tweeted that the decision is “disgraceful.”

This is the man whose lawyers will now ask judges, and Supreme Court Justices, for absolute “deference” to his judgment. I don’t know about the Ninth Circuit, but I don’t see five Justices on the current Supreme Court who’d want to save Trump’s bacon after he has explicitly threatened the entire judicial branch.

In the normal course, the case will now go back to the district court for briefing and a full hearing. Briefs are to be complete on Friday, February 17. Oral argument will surely follow almost at once. Cleared of the atmospherics, the case is close. I think that Washington should win; but at least one judge, Nathaniel Gorton of the District of Massachusetts, has written a full opinion suggesting the order is valid.

It seems most likely that the government’s current plight stems from mere stupidity—from a bull-headed President who rushed through a clumsy order without vetting by the agencies involved and without a senior staff in place at the Justice Department. But Trump’s conduct has been so extraordinary—so seemingly calculated to alienate any judge who is on the fence—that Harvard executive-power guru Jack Goldsmith has suggested that Trump wants to lose the case, in order to set up a confrontation with the courts.

Presidents have thought before that they could roll those wimpy-looking nerds with their gavels and robes. It usually doesn’t work out all that well.