America's top court has ruled that employers who fire workers for being gay or transgender are breaking the country's civil rights laws.
In a 6-3 decision, the Supreme Court said federal law, which prohibits discrimination based on sex, should be understood to include sexual orientation and gender identity.
The ruling is a major win for LGBT workers and their allies, and was made even though the court has grown more conservative.
Lawyers for the employers had argued that the authors of the 1964 Civil Rights Act had not intended it to apply to cases involving sexual orientation or transgender. The Trump administration sided with that argument.
But Judge Neil Gorsuch, who was nominated to the court by President Donald Trump, said acting against an employee on those grounds necessarily takes sex into account.
"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," he wrote. "The limits of the drafters' imagination supply no reason to ignore the law's demands."
What does this mean?
Title VII of the Civil Rights Act of 1964 forbids employers from discriminating against employees on the basis of sex as well as gender, race, colour, national origin and religion.
Under the Obama administration, the federal Equal Employment Opportunity Commission, which enforces the anti-discrimination law, said it included gender identity and sexual orientation. But the Trump administration has moved to roll back some protections in health care and other areas.
What is the reaction?
LGBT advocates hailed the decision.
"Especially at a time when the Trump administration is rolling back the rights of transgender people and anti-transgender violence continues to plague our nation, this decision is a step towards affirming the dignity of transgender people and all LGBTQ people," said Sarah Kate Ellis, president of GLAAD.
"We cannot and should not go back to a time when people felt that had to hide who they are in order to feel safe at work," Alphonso David, president of the Human Rights Campaign, an advocacy group, wrote on Twitter.
The American Civil Liberties Union shared a prepared statement from transgender plaintiff Aimee Stephens, who died last month. Her case was the first major transgender civil rights case heard by America's top court.
"I am glad the court recognised that what happened to me is wrong and illegal," Stephens said. "I am thankful that the court said my transgender siblings and I have a place in our laws - it made me feel safer and more included in our society."
But the Alliance Defending Freedom, a conservative Christian non-profit that asked the court to hear Stephens' case, said it was disappointed in the ruling. It warned it would "create chaos and enormous unfairness for women and girls in athletics, women's shelters and many other contexts".
What did the court say?
In his opinion, Gorsuch said such matters were not before the court.
"The only question before us is whether an employer who fires someone for being homosexual or transgender has discharged or otherwise discriminated against that individual 'because of such individual's sex'," he wrote.
The answer, he said, was "clear" - even if such a scenario had not been anticipated when the law was written.
"It is impossible to discriminate against a person for being homosexual or transgender without discriminating against that individual based on sex," he wrote.
Three conservative justices opposed the ruling: Samuel Alito, Clarence Thomas and Brett Kavanaugh.
"There is only one word for what the court has done today: legislation," Alito wrote in his dissent.
What are the cases?
The ruling resolves three cases brought by people who said they had been fired after their employers learned they were gay or transgender.
Stephens had previously presented as a man at work for six years before writing a letter to colleagues saying she would return to work "as my true self, Aimee Australia Stephens, in appropriate business attire".
Two weeks later, Stephens was fired for insisting in working in women's clothes.
In a court filing last year, the funeral home owner argued it wanted Stephens to comply with a dress code "applicable to Stephens' biological sex".
A lower court sided with Stephens.
Donald Zarda, a skydiving instructor from New York who died in a skydiving accident in 2014 , had filed one of the other cases.
He was dismissed after joking with a female client with whom he was tandem-diving not to worry about the close physical contact because he was "100 percent gay".
The company maintained he was fired because he shared personal information with a client, not because he was gay, but a court in New York ruled in Zarda's favour.
Gerald Bostock, a former child welfare services co-ordinator from Georgia, lost his job after joining a gay recreational softball league, thereby publicly revealing his sexual orientation.
His employer, Clayton County, said his dismissal was the result of "conduct unbecoming of a county employee".
Bostock lost his discrimination case in a federal court in Atlanta.