The U.S. Supreme Court on Monday ruled that existing federal civil rights law prohibits workplace discrimination on the basis of sexual orientation and gender identity.

In a 6-3 decision, the court's majority ruled that such discrimination is prohibited under Title VII of the Civil Rights Act of 1964.

The decision was written by U.S. Associate Justice Neil Gorsuch, who was appointed to the court by President Donald Trump.

“An employer who fires an individual for being homosexual or transgender fires that person for traits or actions it would not have questioned in members of a different sex,” Gorsuch wrote. “Sex plays a necessary and undisguisable role in the decision, exactly what Title VII forbids.”

Associate Justices Brett Kavanaugh – a Trump appointee – Samuel Alito, and Clarence Thomas dissented.

The ruling comes in a trio of consolidated cases involving LGBT employment rights. Two of the cases – Zarda v. Altitude Express and Bostock v. Clayton County – sought clarification on whether sexual orientation is covered under Title VII. The third case, Harris Funeral Homes v. EEOC, involved a transgender plaintiff, Aimee Stephens, who recently died.

(Related: Aimee Stephens, transgender worker involved in Supreme Court case, dies at 59.)

In its filings with the court, the Trump administration supported the employers' position that Title VII does not protect based on sexual orientation and gender identity. The administration reversed Obama-era policies that had asserted Title VII protections for LGBT workers. Monday's ruling could unwind many of those policies, possibly extending LGBT protections nationwide not only in the workplace but also in areas regulated by the federal government such as housing, health care, and education.

The American Civil Liberties Union (ACLU), which was involved in all three cases, called Monday's ruling “a huge victory for LGBTQ equality.”

“The Supreme Court’s clarification that it’s unlawful to fire people because they’re LGBTQ is the result of decades of advocates fighting for our rights,” James Esseks, director of the ACLU's LGBTQ & HIV Project, said in a statement. “The court has caught up to the majority of our country, which already knows that discriminating against LGBTQ people is both unfair and against the law.”