WASHINGTON (CN) — The Supreme Court on Monday ruled federal anti-discrimination protections apply when companies fire people because they are gay or transgender.

“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,” Justice Neil Gorsuch wrote for the six-justice majority. “Sex plays a necessary and undisguisable role in the decision, exactly what Title VII forbids.”

At issue in the dispute is Title VII of the Civil Rights Act of 1964, which, among other things, bars discrimination “because of sex.” The Supreme Court has applied that prohibition in several other contexts, but Monday marks the first time it has weighed in on whether the protections extend to gay and transgender people.

Montana's Democratic candidates for governor Lt. Gov. Mike Cooney and Casey Schreiner weighed in on Monday's ruling.

“Today’s ruling is a victory for all LGBTQ+ Montanans and another step towards equality and justice for all,” Cooney and Schreiner said in a statement. “No Montanan should fear discrimination or be fired because of who they are or whom they love. During Pride month, this is a moment in history we can indeed be proud of.”

The ruling comes in a trio of cases the court considered across two hours of oral argument in October.

One case concerns Gerald Lynn Bostock, who headed the Court Appointed Special Advocates program in Clayton County, Ga. Though he generally received positive performance reviews, the county fired Bostock in June 2013, shortly after he started promoting “Hotlanta,” a gay softball league in which he played.

Bostock’s discussion of the league precipitated several negative comments before his filing.

The court heard Bostock’s claims alongside those of Donald Zarda, a gay skydiving instructor in New York. Zarda often did tandem jumps with customers, requiring him to be strapped tightly to a new jumper.

To calm the nerves of female customers, he would often crack jokes about his sexual orientation. One such joke landed him in trouble with his employer, Altitude Express, after a female customer complained in 2010.

The company fired Zarda, leading him to bring a suit claiming the company fired him because he was gay. Zarda died in a BASE-jumping accident while his case was pending.