In one of its most important decisions in years, the Supreme Court has interpreted federal anti-discrimination law to prohibit discrimination on the basis of sexual orientation or transgender status. In a surprise to most observers, the decision was 6 -3, and written by Justice Neil Gorsuch, one of President Donald Trump's appointees.

The decision marks Gorsuch's most significant move thus far to take on the mantle of the late Justice Antonin Scalia as the intellectual leader of the conservative wing of the court. That may sound strange and counterintuitive: After all, Scalia harshly opposed landmark decisions expanding gay rights, and it's difficult to imagine him having joined the Gorsuch opinion.

Indeed, Justice Samuel Alito explicitly made Scalia the linchpin of his dissent, insisting (not implausibly) that Scalia could not possibly have been on board with a decision like this one. "The court's opinion is like a pirate ship," Alito memorably wrote. "It sails under [Scalia's] flag, but what it actually represents is a theory of statutory interpretation that Scalia excoriated."

Gorsuch's ploy might well work. Conservatives may be briefly frustrated by the outcome of this case. But it is liberals — mostly liberal law professors — who make or break judicial reputations. And liberal legal scholars, who have not liked Gorsuch much thus far, are now going to have to hold him up as a model of judicial honesty. He has applied his method to produce a result against his presumed political preferences. That makes him a hero of legal principle, at least for the moment.

Armed with that reputation, Gorsuch can make the case for himself as a leading judicial intellectual. It worked (to a degree) for Scalia, who was treated by liberals as a serious jurisprudential figure despite deep disagreement with his premises and his conclusions.

The ground on which Gorsuch is fighting is the theory of statutory interpretation known as "textualism." The basic idea is that, when interpreting federal law, judges should not ask what the authors of the law meant to say, or try to divine legislative intent from the Congressional Record or the political context. Rather, textualism says that the overwhelming focus of statutory interpretation should be the words of the law itself: the text.

Pushing this theory was one of Scalia's main contributions to contemporary legal thought. In his mind, textualism discouraged judges from using interpretation to make the law say something different from what the law actually said.

As applied to Title VII, the classic 1964 anti-discrimination law, the textualist idea is very simple. The law prohibits discrimination "on the basis of sex." To discriminate against somebody because of sexual orientation necessarily entails discriminating on the basis of sex. After all, if you're discriminating against a man because he is attracted to men, you would not be discriminating against him if he were a woman who is attracted to men.

The same is true for transgender status. If you are discriminating against somebody for identifying with a gender that differs from their biological sex at birth, you are necessarily discriminating on the basis of sex — because you would not be discriminating against the person if they had the opposite biological sex.

Gorsuch's opinion follows this textualist logic. He got not only all the liberals to join him, but also Chief Justice John Roberts, who loves to show the world that the court's decisions aren't narrowly partisan, thus shoring up the institution's legitimacy (and, cynics would say, building up capital he can later spend reversing liberal precedents).

Alito's anguished response was to quote Scalia as saying that laws should be understood "to mean what they conveyed to reasonable people at the time they were written." Alito pointed out that in 1964, no one thought that banning discrimination on the basis of sex would include banning homophobic or transphobic discrimination.

Gorsuch, Alito maintained, was "updating" an old statute to make it fit new morals — exactly the thing Scalia was trying to block by creating textualism in the first place. Hence, the pirate ship metaphor.

The problem with Alito's objection isn't only that no one thinks Gorsuch was trying to get a liberal result. It's that if Alito's objection were valid, it would undercut textualism itself by turning it into a theory of legislative intent — asking not what the law says, but what it was meant to say. There is nothing new in the meaning of the word "sex" as interpreted by Gorsuch compared to its meaning in 1964.

The upshot is that Gorsuch has done the thing only law professors love (and we love it a lot): He has applied his theory consistently — even when his own political team will not like the result. Now he must be credited with that. This decision is a landmark. And it will mean liberals must treat Gorsuch as a serious justice, not just a Trump minion. This in turn will help Gorsuch's bid to become the new Scalia.

Over time, judicial conservatives will forgive Gorsuch — in the long run, homophobia and transphobia aren't winning causes. And liberals will remember that Gorsuch gave the country a significant win for human equality. You can't take that away from him.

Noah Feldman is a professor of law at Harvard University and was a clerk to U.S. Supreme Court Justice David Souter. He is host of the podcast "Deep Background." His books include "The Three Lives of James Madison: Genius, Partisan, President."