In a major setback for President Trump’s Justice Department, a federal appeals court in New York City has ruled against the administration in determining that the 1964 Civil Rights Act bans discriminating against gay workers.

“We now hold that sexual orientation discrimination constitutes a form of discrimination ‘because of . . . sex,’ in violation of Title VII [of the Civil Rights Act of 1964],” the Court of Appeals for the 2nd Circuit said on Monday.

The case concerned a man, Donald Zarda, who claimed he was terminated from Altitude Express, Inc. because of his sexual orientation. Zarda’s lawyers argued that Title VII of the civil rights law applied to gay people.

The Justice Department argued the law prohibited discrimination based on gender, but not on sexual orientation. It also argued that had Congress wanted the law to prohibit discrimination based on sexual orientation, it would have made that specific.

“There is a common-sense difference between sex discrimination and sexual orientation discrimination,” an attorney for the Trump Justice Department told the court last year.

However, the majority opinion disagreed.

“A woman who is subject to an adverse employment action because she is attracted to women would have been treated differently if she had been a man who was attracted to women,” the majority said in the opinion led by Judge Robert Katzman. “We can therefore conclude that sexual orientation is a function of sex and, by extension, sexual orientation discrimination is a subset of sex discrimination.”

Judge Gerard Lynch led the dissenting opinion, saying Congress “intended to secure the rights of women to equal protection in employment,” not gay workers.

“Put simply, the addition of “sex” to a bill to prohibit employers from ‘discriminat[ing] against any individual with respect to his [or her] compensation, terms, conditions, or privileges of employment, because of such individual’s race, color, religion, . . . or national origin’, was intended to eliminate workplace inequalities that held women back from advancing in the economy, just as the original bill aimed to protect African Americans and other racial, national, and religious minorities from similar discrimination,” Lynch wrote.