Parts of Section 377, which criminalised consensual unnatural sex, are "irrational, indefensible and manifestly arbitrary", the apex court said in its historic ruling.
Consensual gay sex is not a crime, the Supreme Court ruled on Thursday, striking down a British era law that it said violates the right to equality and triggering celebrations among Lesbian, Gay, Bisexual, Transgender and Queer activists who welcomed it as a harbinger of a more inclusive India.
Parts of Section 377 of the Indian Penal Code, which criminalised consensual unnatural sex, are "irrational, indefensible and manifestly arbitrary", the apex court said in its historic ruling that made India the 26th country in the world where homosexuality is legal.
"History owes an apology to members of the community for the delay in ensuring their rights," for denying them their rights and compelling them to live a life of fear, said Justice Indu Malhotra, who was part of the five-judge Constitution bench headed by Chief Justice Dipak Misra that delivered the judgement, capping a 17-year legal struggle.
In its 493-page judgment, the bench said aspects of Section 377 dealing with unnatural sex with animals and children remain in force.
"Any kind of sexual activity with animals shall remain a penal offence under Section 377 of the IPC," it said.
Delivering four separate but concurring judgements, the top court set aside its 2013 verdict which had re-criminalised consensual unnatural sex.
Argentina (2010)
Greenland (2015)
South Africa (2006)
Australia (2017)
Iceland (2010)
Spain (2005)
Belgium (2003)
Ireland (2015)
United States (2015)
Brazil (2013)
Luxembourg (2014)
Sweden (2009)
Canada (2005)
The bench, which also comprised Justices R F Nariman, A M Khanwilkar and D Y Chandrachud, struck down part of Section 377 of the Indian Penal Code as being violative of the right to equality and the right to live with dignity.
Dealing with a clutch of petitions, it held that Section 377 was used as a weapon to harass members of the LGBTQ community, resulting in discrimination.
Across the country, gay people gathered in front of their television sets, waited anxiously for the verdict to be announced.
Tears flowed and people hugged each other spontaneously, when the judgment flashed across their television and mobile phone screens.
Many cut cakes and unfurled rainbow flags, a symbol of gay pride, to welcome the verdict, which also said society cannot dictate a sexual relationship between consenting adults.
Filmmaker Karan Johar, who has often spoken out on the issue of gay rights, said the judgment was a "huge thumbs up" for humanity.
"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!" he wrote on Twitter.
The judgment came on a batch of writ petitions filed by dancer Navtej Jauhar, journalist Sunil Mehra, chef Ritu Dalmia, hoteliers Aman Nath and Keshav Suri and business executive Ayesha Kapur as well as 20 former and current students of the IITs.
They had sought decriminalisation of consensual sex between two consenting adults of the same sex by declaring Section 377 -- enacted 158 years ago -- illegal and unconstitutional.
CJI Misra, who wrote the judgement for himself and Justice Khanwilkar, said the denial of self expression was akin to inviting death.
The bench said courts must protect the dignity of an individual as right to live with dignity is recognised as fundamental right.
It termed sexual orientation a "biological phenomenon" and held any discrimination on this ground was violative of fundamental rights.
Describing the verdict as landmark, Anjan Joshi, member of the Society for People, Awareness, Care and Empowerment, said it was a start.
"We know we have a long way to go in terms of right to adoption, right to marriage but it is a very welcome beginning," Joshi said.
The Congress also put out a Twitter post welcoming the judgement.
"We join the people of India & the LGBTQIA+ community in their victory over prejudice. We welcome the progressive & decisive verdict from the Supreme Court & hope this is the beginning of a more equal & inclusive society," it said, adding intersex and asexuality to LGBTQ.
On the other end of the political spectrum, the Rashtriya Swayamsevak Sangh said in a statement that while it doesn't see homosexuality as a crime, such relationships were not "compatible with nature" and so it does not support them.
The United Nations in India welcomed the verdict, saying sexual orientation and gender expression form an integral part of an individual's identity the world over. Violence, stigma and discrimination based on these attributes constitute an "egregious" violation of human rights, it said.
Justice Chandrachud, while reading out the operative portion of his verdict, said members of the LGBTQ community were targeted and exploited due to Section 377. They have constitutional rights like that of any other citizen, he said.
Observing that the Constitution nurtured dissent as a "safety valve" of society, he said "we cannot change the history but can pave a way for better future".
The apex court noted that India is a signatory of international treaties on rights of LGBTQ and it was obligatory to adhere to them.
The issue was first raised by the NGO, Naaz Foundation, which approached the Delhi high court in 2001.
In 2009, the Delhi high court decriminalised sex between consenting adults of the same gender.
This was overturned in 2013 by the apex court which also dismissed the review plea against which the curative petitions were filed.
Section 377 had made "carnal intercourse against the order of nature" punishable by imprisonment for life.
FAQ: What is Section 377?
Fight against Section 377: The journey so far
Would ancient India have supported Section 377?
This couple is proud to be GAY