If there were any lingering doubt that Donald Trump’s latest plan to curb asylum is flatly unlawful, Judge Jay Bybee quashed it on Friday.

In a meticulous 65-page opinion, Bybee—a conservative George W. Bush appointee—explained that the president cannot rewrite a federal statute to deny asylum to immigrants who enter the country without authorization. His decision for the 9th U.S. Circuit Court of Appeals is a twofold rebuke to Trump, halting the president’s legal assault on asylum-seekers and undermining his claim that any judge who blocked the order is a Democratic hack. The reality is that anyone who understands the English language should recognize that Trump’s new rule is illegal. Like so many of Trump’s attention-grabbing proposals, this doomed policy should never have been treated as legitimate in the first place.

Friday’s ruling involves a proclamation that Trump signed on Nov. 9, ostensibly to address the “continuing and threatened mass migration of aliens with no basis for admission into the United States through our southern border.” The order alluded darkly to the caravan of asylum-seekers then approaching the border, which Trump tried and failed to exploit as a campaign issue. To remedy this “crisis” and protect “the integrity of our borders,” he directed the federal government to deny asylum to any immigrant who enters the United States unlawfully.

Ten days later, U.S. District Judge Jon S. Tigar halted the new rule, holding that it likely exceeded the president’s authority. Trump responded by dismissing Tigar, a Barack Obama appointee, as an “Obama judge.” The comment led to a rare rebuke from Chief Justice John Roberts, who told the AP: “We do not have Obama judges or Trump judges, Bush judges or Clinton judges. What we have is an extraordinary group of dedicated judges doing their level best to do equal right to those appearing before them.”

As Trump escalated his feud with Roberts, his Department of Justice appealed Tigar’s ruling to the 9th Circuit. It faced a seemingly propitious panel: Bybee, Judge Edward Leavy, and Judge Andrew D. Hurwitz. Bybee is a very conservative jurist who authored the original “torture memo,” justifying the Bush administration’s brutal interrogation of detainees. Leavy is a staunchly conservative Reagan appointee; only Hurwitz, an Obama appointee, leans to the left. Under Trump’s partisan vision of the judiciary, the DOJ would seem to have a good shot at reviving the asylum rule.

Obviously, the Trump administration has not persuaded Congress to overhaul asylum law.

But Bybee didn’t bite. In a crisp and rigorous opinion for the court, he wrote that Tigar was correct to conclude that the policy almost certainly violates the law. The problem, Bybee explained, is that Congress expressly provided asylum-seekers with the right that Trump now seeks to revoke: an ability to apply for asylum regardless of how they came into the country. The Immigration and Nationality Act states that “[a]ny alien who is physically present in the United States or who arrives in the United States (whether or not at a designated port of arrival …), irrespective of such alien’s status, may apply for asylum in accordance with this section.” This provision implements the 1951 Convention Relating to the Status of Refugees, which the United States has ratified. It directs signatories not to “impose penalties [on refugees] on account of their illegal entry or presence.”

The plain text of the law couldn’t be clearer: Immigrants in the U.S. are eligible for asylum whether they arrived legally (through a “designated port of arrival”) or illegally. If the president wants to change that fact, he’ll have to convince Congress to break its treaty obligations and alter the law.

Obviously, the Trump administration has not persuaded Congress to overhaul asylum law. So it tried to work around the existing statute by allowing unauthorized immigrants to request asylum—then directing the government to deny their application. Bybee easily disposed of this semantical workaround. “It is the hollowest of rights,” he wrote, “that an alien must be allowed to apply for asylum regardless of whether she arrived through a port of entry if another rule makes her categorically ineligible for asylum based on precisely that fact. … The technical differences between applying for and eligibility for asylum are of no consequence to a refugee when the bottom line—no possibility of asylum—is the same.”

In light of the proclamation’s fundamental illegality, Bybee, joined by Hurwitz, affirmed Tigar’s nationwide restraining order. Leavy dissented in a curious five-page opinion insisting that the INA grants the executive branch power “to bring safety and fairness to the conditions at the southern border.” His anemic analysis is no match for Bybee’s thorough demolition of the DOJ’s illogical position. It seems quite likely that a lopsided majority of the Supreme Court will eventually agree with Bybee’s majority opinion.

It is satisfying to see a “Bush judge” (in Trumpian parlance) hand the president such a stinging legal defeat. Roberts overstated the case in totally dismissing the role of partisanship in the judiciary; of course some judges are political. But for now, a majority of the federal judiciary remains willing to stand up to the president, at least when he issues blatantly illegal orders. Judges like Roberts and Bybee may let Trump manipulate ambiguous laws to do some very bad things to immigrants. But they are not willing to let the president ignore a clear and constitutional directive from Congress.

The next time Trump floats a flagrantly lawless idea, then, it’s worth remembering that nativist bluster cannot transmogrify an illegitimate command into a permissible executive order. Just because the president considers ending citizenship for the children of unauthorized immigrants, for instance, does not mean he can actually get away with it. Like the INA, the Constitution grants certain rights that the president cannot unilaterally rescind—including birthright citizenship. Bybee felt no compunction to pretend that Trump’s illicit scheme has any legitimacy. Neither should the rest of us.