President Donald Trump often promised his supporters two things: that he would nominate a Supreme Court justice in the mold of Antonin Scalia, and that he would crack down on legal and undocumented immigrants alike. One of those pledges just undercut the other.

The Supreme Court struck down a provision of federal immigration law on Tuesday that made it easier for the government to deport immigrants with state criminal convictions. Justice Neil Gorsuch, a Trump appointee, joined with the court’s four liberals for the first time during his tenure to rule that the provision, which determined what counts as a “crime of violence” for deportation purposes, was unconstitutionally vague.

In his concurring opinion, the court’s newest justice dropped his usual folksy writing style for a more stentorian tone, one that evoked the stern language of his predecessor, Scalia. “A government of laws and not of men can never tolerate that arbitrary power,” Gorsuch wrote. “And, in my judgment, that foundational principle dictates today’s result.”

The case, Sessions v. Dimaya, concerned the fate of James Dimaya, a green-card holder born in the Philippines. In 1992, when he was 13 years old, Dimaya immigrated to the United States and has lived in the country ever since. His legal troubles began after he pleaded no contest to residential burglary charges in California, first in 2007 and again in 2009. In 2010, the government began deportation proceedings.

Under federal immigration law, non-citizens can be removed from the country if they commit an “aggravated felony” after entering the United States. What counts as an aggravated felony? The Immigration and Naturalization Act lists numerous state and federal crimes that qualify, such as murder and rape, and incorporates the residual clause from Section 16 of the federal code to determine other felonies that may be considered a “crime of violence.”

An immigration judge first approved Dimaya’s deportation on the grounds that the California burglary charges amounted to a “crime of violence” under federal law. Section 16(a) of the federal code defines a “crime of violence” as an offense involving “the use, attempted use, or threatened use of physical force against the person or property of another.” That seems clear enough—and doesn’t apply to Dimaya, since he was accused of no such thing.

So for his deportation, the government relied on Section 16(b)—the residual clause. It defines a crime of violence as including a felony “that, by its nature, involves a substantial risk that physical force against the person or property of another may be used in the course of committing the offense.” (Emphasis mine.) That’s much less clear. The phrase “a substantial risk” practically encourages some degree of speculation from the courts, which is why, on appeal, Dimaya asked the Ninth Circuit Court of Appeals to stop his removal and strike down the clause as unconstitutionally vague. A three-judge panel did just that.

The panel’s ruling relied heavily on the 2015 Supreme Court case Johnson v. United States, in which the court wrestled with a similar adversary: the residual clause of the Armed Career Criminal Act. It allowed federal prosecutors to seek additional prison time for defendants who illegally own firearms if they had previously committed what the clause defines as a “violent felony.” Instead of a ten-year prison sentence, defendants could receive anywhere from 15 years to a life sentence.

Congress listed a number of crimes in the ACCA that would qualify, then tacked on the residual clause to cover any other crimes that involved “a serious potential risk of physical injury” to others. That imprecise phrasing bedeviled federal courts for years thereafter. So hazy was its definition that Samuel Johnson, the case’s namesake, received a longer sentence for once owning a short-barreled shotgun in violation of Minnesota law. Led by Antonin Scalia, the justices ruled 8-to-1 to strike down his sentence and 6-to-3 to find the law unconstitutionally vague.

“It has been said that the life of the law is experience. Nine years’ experience trying to derive meaning from the residual clause convinces us that we have embarked upon a failed enterprise,” Scalia wrote for the majority. “Invoking so shapeless a provision to condemn someone to prison for 15 years to life does not comport with the Constitution’s guarantee of due process.”

Scalia’s antipathy towards vague and poorly written laws often put him at odds with the court’s conservatives when criminal statutes came under scrutiny. It sprang from his oft-expressed disdain for Congress’ habits of writing numerous laws and vague laws, which he viewed as a threat to liberty especially in combination. The court’s majority in Dimaya took a similarly hostile approach to Section 16(b).

Taking the government’s approach “would condemn us to repeat the past—to rerun the old ACCA tape, as though we remembered nothing from its first showing,” Justice Elena Kagan wrote for the majority. “But why should we disregard a lesson so hard learned? ‘Insanity,’ Justice Scalia wrote in the last ACCA residual clause case before Johnson, ‘is doing the same thing over and over again, but expecting different results.’ We abandoned that lunatic practice in Johnson and see no reason to start it again.”

Gorsuch echoed her concerns. “No amount of staring at the statute’s text, structure, or history will yield a clue,” he wrote. “Nor does the statute call for the application of some pre-existing body of law familiar to the judicial power. The statute doesn’t even ask for application of common experience. Choice, pure and raw, is required. Will, not judgment, dictates the result.”

Scalia would be proud. The Trump administration, on the other hand, was less than thrilled. “Today’s ruling,” Department of Homeland Security spokesman Tyler Houlton said in a statement, “significantly undermines DHS’s efforts to remove aliens convicted of certain violent crimes, including sexual assault, kidnapping, and burglary, from the United States. By preventing the federal government from removing known criminal aliens, it allows our nation to be a safe haven for criminals and makes us more vulnerable as a result.”

And Trump himself weighed in on Tuesday evening:

As if anticipating this reaction, Gorsuch took care to explain the limits of Tuesday’s ruling. He noted that the statute already listed many major crimes that made non-citizens eligible for deportation; those would be unaffected by Section 16(b)’s absence. “We address only the statute’s ‘residual clause’ where Congress ended its own list and asked us to begin writing our own,” he explained. The legislature, he added, “remains free at any time to add more crimes to its list. It remains free, as well, to write a new residual clause that affords the fair notice lacking here.”

That may not be what the administration wanted to hear, given its zeal for deportations and its difficulty getting even modest legislation through a Republican-led Congress. But it’s the answer it should’ve expected when Trump promised to put another Scalia on the court.