A federal appeals court ruled today that workers can’t be fired based on their sexual orientation.

The federal appeals court in New York today issued a victory for lesbian, gay, and bisexual people, ruling that workers can’t be fired based on their sexual orientation and rebuffing the Trump administration’s insistence that they can.

That might sound like common sense, but in two decisions from the 2000s, the Court of Appeals for the Second Circuit wrongly concluded that discriminating against gay people isn’t prohibited by Title VII of the Civil Rights Act of 1964, the federal law that bans sex discrimination in the workplace. Last spring, the court agreed to take a fresh look at the question following a landmark decision by the federal appeals court in Chicago recognizing that discrimination based on sexual orientation is illegal sex discrimination.

As the court today rightly noted, there is no way to separate discrimination based on sexual orientation from discrimination based on sex. That’s because, to “identify the sexual orientation of a particular person, we need to know the sex of the person and that of the people to whom he or she is attracted.” The court noted the futility of trying to parse the evidence in such cases, as illustrated by judges tallying up “epithets such as ‘ass wipe,’ ‘fag,’ ‘gay,’ ‘queer,’ ‘real man,’ and ‘fem’ to determine whether discrimination is based on sex or sexual orientation.” As the decision acknowledged, such “lexical bean counting” is absurd and unwarranted, because discrimination against gay people is based on both.

In rejecting efforts to artificially limit the scope of sex discrimination to exclude lesbian, gay, and bisexual people, the Second Circuit noted important historical parallels that the ACLU raised in its amicus brief. It would be unthinkable today, for example, to say that sexual harassment is perfectly lawful under federal law. But courts did not always understand it to be sex discrimination, initially dismissing sexual harassment claims out of hand in the 1970s, and recognizing such conduct as unlawful only after a Supreme Court ruling in 1986. So, too, courts that once discounted sexual orientation discrimination claims now recognize it to be not only wrong, but illegal.

The Second Circuit’s opinion is an important victory for LGBT people. It’s also a big defeat for the Trump administration, which stepped in gratuitously to tell the court that employers should be free to fire LGBT people under federal law. That move was disappointing, but perhaps not surprising, given the administration’s efforts to embolden discrimination against LGBT people at work, at school, and in daily life. President Trump may be a bully, but he doesn’t get the last word on LGBT people’s rights.