New York — Gay workers and their corporate supporters won a legal victory over the Trump administration as a federal appeals court ruled on Monday that firing people over their sexual orientation is a form of illegal sex discrimination.

The appeals court in Manhattan overturned its own previous rulings, saying “legal doctrine evolves.” It’s the second ruling in the U.S. to break with precedent in finding that workplace discrimination based on sexual orientation is illegal. A third appeals court ruled the other way last year. The split among the courts sets up a possible Supreme Court showdown.

“Sexual orientation discrimination — which is motivated by an employer’s opposition to romantic association between particular sexes — is discrimination based on the employee’s own sex,” Judge Robert Katzmann wrote in an opinion for the full court’s majority.

Skydiving instructor Donald Zarda claimed he was fired by Altitude Express Inc. because he was gay. He argued that Title VII of the Civil Rights Act of 1964, which bars workplace discrimination on the basis of sex, race, color, national origin and religion also includes sexual orientation. Zarda, who sued in 2010, died in a base-jumping accident in Switzerland in 2014. His estate carried on with the case.

A panel of three appeals court judges ruled against Zarda in April. He was granted a rehearing before the full appeals court, which has authority over federal courts in New York, Connecticut and Vermont. In the majority opinion, Katzmann said sexual-orientation stereotyping falls within Title VII’s prohibition against discrimination “because sex is necessarily a factor in sexual orientation.”