India's top court legalizes gay sex in historic verdict The verdict was greeted with scenes of jubilation across the country.

The world's largest democracy just struck down a ban on gay sex.

On Thursday, India's top court declared parts of Section 377 unconstitutional, in a historic decision that finally brings to end a colonial-era ban many have long fought to dismantle and that may herald a change in countries across the world.

"To deny the LGBT community of their right to sexual orientation is a denial of their citizenship and a violation of their privacy," said Justice D.I.Y. Chandrachud, one of a five-judge bench in the Supreme Court who delivered the verdict. "They cannot be pushed into obscurity by an oppressive colonial legislation."

Justice Indu Malhotra, the only woman on the bench, acknowledged the harm the law had done.

"History owes an apology to LGBT persons for ostracisation, discrimination," she said.

The verdict was greeted with scenes of jubilation, as gay people across the country hugged, cried, danced and waved flags.

Hotelier and chef Ritu Dalmia, who was one of the group of five petitioners first challenging the ban, told ABC News she hadn't been able to hold back her tears.

"This really is a good day for human rights and democracy," she said.

LGBT activist Harish Iyer said that the landmark verdict was the first step in a long road towards social acceptance in Indian society, large parts of which still hold deeply conservative views.

"We are free. The door of the closets are finally open," he told ABC News. "But we don't have time to rest on our laurels. This is just the beginning of our fight to tell our story in its full glory."

It's not just India that is affected by the verdict.

The original law had reverberated far beyond India, including in countries where gay people still struggle for acceptance, Jessica Stern, the executive director of the New York-based rights group OutRight Action International, told the Associated Press.

“The sodomy law that became the model everywhere, from Uganda to Singapore to the U.K. itself, premiered in India, becoming the confusing and dehumanizing standard replicated around the world,” she said in a statement, saying “today’s historic outcome will reverberate across India and the world.”

This is just the beginning of our fight to tell our story in its full glory

The ruling Bharatiya Janata Party, usually vocal on conservative issues, seemed to signal its acceptance by largely refraining from comment.

Its main opposition, the Congress party, tweeted, "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."

India's relationship with homosexuality has changed over time. Hinduism, its primary religion, was historically tolerant of same-sex love, but after British colonizers introduced their more conservative laws and ways of thinking, stigma began to build.

Section 377, a relic of Victorian England, was laid down in India in 1861, and says that “whoever voluntarily has carnal intercourse against the order of nature” can be punished with up to 10 years in prison.

India gained independence from Britain in 1947 but the statute remained on the books until 2009 when it was struck down — only to be reinstated four years later.

Although the law is not often invoked to jail people, the threat of it is used as a tool of repression, blackmail and extortion by society and by law enforcement.

"The very presence of Section 377 is a threat to our dignity and life," Rituparna Borah, a queer feminist activist, told ABC. "Queer people are blackmailed and stigmatized everyday, even by the police."

Anjali Gopalan, who heads Naz Foundation, the organization that spearheaded the fight against Section 377, told ABC she first began the legal battle in 2001 on realizing the law was getting in the way of social reform efforts.

"When we gave out condoms, for example, we had to face constant interference by authorities," she said. "Our workers were harassed. Complaints were filed against us. They told us we were carrying out illegal activity."

The last straw was when a young, traumatized queer man came to Naz India for help. "His parents had taken him to hospital where they gave him shock treatment to try and 'cure' him," she said.

And thus began the 17-year long struggle against Section 377 -- with bumps along the way. The law's ban on gay sex was struck down by the Delhi High Court in 2009, then reinstated as a criminal offense in 2013 by the Supreme Court, which said that only a “minuscule fraction of the country’s population" would be affected and reprimanded the high court for "overreaching" in its "anxiety to protect the so-called rights of LGBT persons."

Dalmia, the hotelier and chef, said the idea held by the judges that those affected were an invisible minority shocked her and motivated her to publicly join the renewed legal fight. Already a well-known name among the country's social circles, she decided to lend her influence to the cause.

"When the judge implied that there were not many victims, I couldn't believe it," she said. "I realized we all sit and complain but things won't change if someone doesn't do something."

Dalmia and her partner had been together for a long time, but they couldn't be married, their health insurance wouldn't accept the other as family, and they couldn't get joint bank accounts.

But now, she said, a new chapter in the fight against such injustice was beginning.

Not everyone was on board with the verdict.

“It’s shameful,” said Swami Chakrapani, president of All India Hindu Mahasabha, a conservative Hindu group, the New York Times reported. “We are giving credibility and legitimacy to mentally sick people.”

And that's why activists must prepare for the uphill battle that combating homophobia will present, said Iyer, the activist.

"Changing the law is only the first step, the bigger task is changing hearts and minds," he said. "We want freedom from bullying, protection against workplace discrimination, recognition of civil partnerships. We want equality not in part, but in totality."