In a historic decision, India's Supreme Court has ruled that gay sex is no longer a criminal offence.
The ruling overturns a 2013 judgement that upheld a colonial-era law, known as section 377, under which gay sex is categorised as an "unnatural offence".
The court has now ruled discrimination on the basis of sexual orientation is a fundamental violation of rights.
Campaigners outside the court cheered and some broke down in tears as the ruling was handed down.
Although public opinion in India's biggest cities has been in favour of scrapping the law, there remains strong opposition among religious groups and in conservative rural communities.
challenged. As such, it represents a huge victory for India's LGBT community.
What have the judges said?
Thursday's ruling was delivered by a five-judge bench headed by India's outgoing chief justice Dipak Misra and was unanimous.
Reading out the judgement, he said: "Criminalising carnal intercourse is irrational, arbitrary and manifestly unconstitutional."
Another judge, Indu Malhotra, said she believed "history owes an apology" to LGBT people for ostracising them.
Justice DY Chandrachud said the state had no right to control the private lives of LGBT community members and that the denial of the right to sexual orientation was the same as denying the right to privacy.
The ruling effectively allows gay sex among consenting adults in private.
What is section 377?
It is a 157-year-old colonial-era law which criminalises certain sexual acts as "unnatural offences" that are punishable by a 10-year jail term.
The law punishes, in its own words, "carnal intercourse against the order of nature with any man, woman or animal".
While the statute criminalises all anal and oral sex, it has largely affected same-sex relationships.
Human rights groups say police have used the statute to harass and abuse members of the LGBT community.
'Recognising everyone's right to love'
Geeta Pandey, BBC News, Delhi
Even though it was rarely invoked when it involved consenting adults, section 377 could be - and was sometimes - used as a tool for harassment. It is not surprising then that campaigners are describing the verdict as a "new dawn for personal liberty".
But in a largely conservative India, where leaders of all religions have consistently opposed gay sex, it will still be a while before attitudes change and the community finds full acceptance.
But laws almost always play an important role in changing mindsets, and by recognising the community's right to love, the Supreme Court has restored the dignity denied to them for a very long time.
How did we get to this point?
It's been a tortuous route. A bid to repeal section 377 was initiated in 2001 and was batted between court and government until 2009, when the Delhi High Court ruled in favour of decriminalisation.
Several political, social and religious groups then mobilised to restore the law and in 2013 the Supreme Court struck down the High Court ruling.
Anti-section 377 activists then submitted a "curative petition" - a formal request to review an earlier court order perceived as a "miscarriage of justice" - and in 2016 the Supreme Court decided to revisit its ruling.
What has the LGBT reaction been to the latest ruling?
One of joy given that the community has fought vigorously to strike down the law.
Equal rights activists had argued that the very existence of such a law was proof of discrimination based on sexual orientation.
LGBT activist Harish Iyer told the BBC: "I'm absolutely elated. It's like a second freedom struggle where finally we have thrown a British law out of this country... I think the next step would be to get anti-discrimination laws in place, or anti-bullying laws."
Messages of support were posted on Twitter, including from film director Karan Johar:
Historical judgment!!!! So proud today! Decriminalising homosexuality and abolishing #Section377 is a huge thumbs up for humanity and equal rights! The country gets its oxygen back! ????????? pic.twitter.com/ZOXwKmKDp5
— Karan Johar (@karanjohar) September 6, 2018
Journalist Anna MM Vetticad said India had been saved from its shame:
We are witnessing history being made. Hats off to all my #LGBT rights activist friends who have battled hard to get here. You have saved India from the shame of being one of the remaining countries in the world that criminalises #homosexuality - thank you for that. #Section377
— Anna MM Vetticad (@annavetticad) September 6, 2018
What else was said in the ruling?
The court said other aspects of section 377 dealing with unnatural sex with animals and children would remain in force.
The judges also explicitly said that they only ruled on the constitutional validity of section 377 and were not looking at it in terms of other rights such as those related to marriage or inheritance.
It remains too early to say what this will translate to in the longer term.
Source: BBC