Section 377 was introduced in 1861 during the British rule. Modelled after erstwhile's Britain's Buggery Act of 1533 which criminalised sodomy, the law criminalised homosexual acts and sexual acts that were considered "against the natural order", which is described as:
"Whoever voluntarily has carnal intercourse against the order of nature with any man, woman or animal, shall be punished with imprisonment for life, or with imprisonment of either description for a term which may extend to ten years, and shall also be liable to fine."
It remained a law from 1861 to well into 2009, when the Delhi High Court issued a landmark judgement in the Naz Foundation lawsuit, legalising homosexuality across the country. To the hitherto underground LGBTQ community, the judgement was a recognition of their rights.
However, religious leaders were having none of it. Despite their inherent differences when it comes to various matters, many religious leaders and organisations came together in opposing the idea of repealing Section 377, and later condemned the HC ruling, saying that it would "damage" the "moral fabric" of society.
The happiness was short-lived, however, as the Supreme Court overturned the judgement of the high court citing, holding that only Parliament can change laws. A bench of justices G S Singhvi and S J Mukhopadhaya said the high court verdict, which read down Section 377 (reduced it's scope of application) in 2009, was not right as there was no record of its abuse since only 200 people were prosecuted so far under the law.
The move came after a long-winded appeal against the high court verdict started by the Delhi Commission for Protection of Child Rights, with proponents like Ramdev, who had already opposed the Delhi HC order and had gone on record saying he could "cure" homosexuality using 'yoga'.
In December 2013, while the Congress was opposing recriminialsation of gay sex, various minority leaders came in support of the BJP which supported the apex court judgement, and the RSS, in challenging the UPA's review petition on the matter.
In 2014, however, the gay rights groups got a ray of hope as the Supreme Court agreed to hear a curative plea against its 2013 judgement.
In 2016, the apex court sent the petition to a five-judge constitution bench, opening a legal debate on homosexuality and the validity of Section 377. The move was openly welcomed by the opposition Congress, while the ruling BJP remained wary, with some members of the party remaining headstrong on their comments against homosexuality and others, most notably Arun Jaitley, opposing the 2013 judgement.
As time went on, the apex court came to describe its 2013 judgement as "unsustainable" in light of its landmark Right to Privacy judgement, with Justice J Chalameshwar saying he did not think that anybody would like to have the officers of the state intruding into their homes or private property at will or soldiers quartered in their houses without their consent.
In January 2018, data revealed that over 4,700 cases had been filed under Section 377 of the IPC since the SC judgement in 2013, with Uttar Pradesh topping the chart with 999 cases.
In April, the apex court agreed to hear fresh pleas against Section 377. The petitioners contended that Section 377, that penalised voluntary carnal intercourse, violated their fundamental rights to privacy, dignity and autonomy under the Constitution, and in July, refused to allow the Centre to defer the hearing on the matter. The Centre eventually decided to 'leave the decision' to the apex court, while the health ministry once again went on record with its stand to decriminalise 377.
And finally, we come to the day when the apex court decriminalises homosexuality, with the Chief Justice of India saying, "No one can escape from their individualism. Society is now better for individualism," and all four judges concurring.