In a surprise decision, the conservative-leaning U.S. Supreme Court ruled on Monday morning that LGBTQ workers are protected by the Civil Rights Act of 1964.

The 6-3 decision officially determined that people cannot be fired for their gender identity or sexual orientation and that doing so would be a violation of Title VII of the Civil Rights Act of 1964, CNN reported.

"Sometimes small gestures can have unexpected conse­quences. Major initiatives practically guarantee them. In our time, few pieces of federal legislation rank in signifi­cance with the Civil Rights Act of 1964. There, in Title VII, Congress outlawed discrimination in the workplace on the basis of race, color, religion, sex, or national origin," the court wrote in the majority opinion.

"Today, we must decide whether an employer can fire someone simply for being homosexual or transgender. The answer is clear. An employer who fires an individual for being ho­mosexual or transgender fires that person for traits or ac­tions it would not have questioned in members of a different sex. Sex plays a necessary and undisguisable role in the decision, exactly what Title VII forbids," the court added. 

The case involved three instances where people were fired shortly after revealing to their employer that they were homosexual or transgender. 

Gerald Bostock worked for Clayton County, Georgia, as a child welfare advocate, Donald Zarda was a skydiving instructor at Alti­tude Express in New York and Aimee Stephens worked at R.G. & G.R. Harris Funeral Homes in Michigan. All three were removed from their positions after telling their employer about their identity or revealing it in another context.

The decision notes that both Zarda and Stephens died before the decision came out, but their estates have pushed forward with the case in their honor.

According to the justices, the focus of the case was on the definition of "sex" and whether it included gender identity and sexual orientation. They ruled that an employer violates Title VII "when it inten­tionally fires an individual employee based in part on sex."

"It doesn’t matter if other factors besides the plaintiff ’s sex contributed to the decision. And it doesn’t matter if the em­ployer treated women as a group the same when compared to men as a group. If the employer intentionally relies in part on an individual employee’s sex when deciding to dis­charge the employee—put differently, if changing the em­ployee’s sex would have yielded a different choice by the employer—a statutory violation has occurred. Title VII’s message is 'simple but momentous': An individual em­ployee’s sex is 'not relevant to the selection, evaluation, or compensation of employees," they wrote.

"The statute’s message for our cases is equally simple and momentous: An individual’s homosexuality or transgender status is not relevant to employment decisions. That’s be­ cause it is impossible to discriminate against a person for being homosexual or transgender without discriminating against that individual based on sex," the justices added.

To the surprise of many, Justice Neil Gorsuch and Chief Justice John Roberts voted with the liberal members of the court in favor of LGBTQ protections while Justice Brett Kavanaugh, Justice Clarence Thomas and Justice Samuel Alito voted against them. 

In the decision, Gorsuch — who was appointed by President Donald Trump and who wrote the majority opinion — said that "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."

According to The New York Times, Stephens died on May 12. In 2013 she told her colleagues at the funeral home where she worked that she would be presenting as a woman and was fired for it. 

“What I must tell you is very difficult for me and is taking all the courage I can muster. I have felt imprisoned in a body that does not match my mind, and this has caused me great despair and loneliness,” Stephens said to her co-workers in 2013, according to The Times. 

NBC News reported that 21 states already had laws in place protecting LGBTQ workers and seven other states only provided protection for people working for the state. Monday's ruling extends those protections to the entire country.