The top court in the US 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 it comes even though the court has become 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 and gender identity. 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.
Members of the LGBT community across the US were celebrating on hearing the news.
'An emotional day'
Sean K Heslin, Palm Springs, California
Today's Supreme Court ruling brought me to tears.
As a gay man lucky enough to live in California and originally come from New York I've never had to personally worry about losing a job or not being hired simply because of my sexual orientation.
But as a financial adviser working with clients all around the country for over 30 years, I've heard countless stories of people who have lost their jobs simply for being gay. It's angered and saddened me for so long.
For years now, I have been speaking at seminars or with friends and family about how in this day and age it's still perfectly legal to fire someone just because they're gay. Many people didn't believe me. Until today.
What does the ruling 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 healthcare and other areas.
While some states in the US had already explicitly extended such protections to LGBT workers, many have not.
It's difficult to overstate the significance of the decision.
While the court is establishing a long history of decisions expanding gay rights, this is the first time it spoke directly about the legal protections for transgender individuals.
That the ruling comes out just days after the Trump administration announced it was removing transgender health-insurance protections only puts the issue in stark relief.
Transgender rights is becoming a political battlefield, and a majority of the Supreme Court just announced which side it's on.
What have campaigners said?
LGBT advocates hailed the decision as the end of people hiding their sexuality at work.
"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.
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," Ms 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 Ms 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, Mr 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.
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.
Ms 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, Ms Stephens was fired for insisting in working in women's clothes.
In a court filing last year, the funeral home owner argued it wanted Ms Stephens to comply with a dress code "applicable to Stephens' biological sex".
A lower court sided with Ms 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% 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 Mr 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".
Mr Bostock lost his discrimination case in a federal court in Atlanta.
Other key moments in US LGBT history
- Jan 1958 - US Supreme Court rules for first time in favour of LGBT rights, saying an LGBT magazine, deemed obscene by the FBI and postal service, had First Amendment rights
- July 1961 - Illinois becomes first state to decriminalise homosexuality
- June 1969 - Protests begin after police raid Stonewall Inn in New York City, now seen as start of gay rights movement
- Sept 1996 - President Clinton defines marriage as union between "one man and one woman"
- June 2003 - US Supreme Court determines sodomy laws to be unconstitutional
- Oct 2009 - Democratic President Obama signs Matthew Shepard and James Byrd Jr Hate Crimes Law, expanding hate crime laws to include sexual orientation
- June 2015 - US Supreme Court rules 5-4 that same-sex marriage is legal across the country
- June 2016 - The Pentagon lifts its ban on transgender Americans serve in the military
- March 2018 - Republican President Trump issues a policy banning transgender Americans from serving in military