Members of lesbian, gay, bisexual and transgender groups held tearful celebrations in cities across the South Asian nation of 1.25 billion people as the historic verdict was read out.

“The law had become a weapon for harassment for the LGBT community,” said chief justice Dipak Misra as he quashed the cornerstone of Section 377, a law introduced by British rulers in 1861. “History owes an apology to the members of this community and their families, for the delay in providing redressal for the ignominy and ostracism that they have suffered through the centuries,” added the ruling.

India is now one of more than 120 countries to have effectively decriminalised homosexuality. While the court ruling only legalises sexual acts between adults, gay activists have hailed the verdict as a major boost in the deeply conservative country where religious groups have fiercely opposed any liberalisation of sexual morality. Activists had been fighting the ban since the 1990s, suffering several court reversals before Thursday’s verdict. The Delhi High Court decriminalised gay sex in 2009, but the Supreme Court reinstated the ban in 2014 after an appeal by religious leaders.

According to official data, seven people were convicted on charges of “unnatural offences” and 16 acquitted in 2016.

“It was a law that propagated homophobia,” said Keshav Suri, one of the petitioners against Section 377, who organised a Bollywood-style dance show at his family’s luxury Delhi hotel to celebrate the court victory.

“In rural areas it is a harassment tool, used by cops, used by authorities for extortion”, Suri told AFP in an interview ahead of the verdict.

Many Indian gay professionals have moved to Canada and Europe where they are more accepted, added the businessman who married his partner in Paris this year. India’s conservative government had opposed ending Section 377 but said ahead of the hearing that it would leave the decision to the “wisdom” of the Supreme Court.

It had warned, however, that judges should not change other aspects of Indian law, such as the right to marriage. Members of the LGBT community hugged each other and cried outside the Supreme Court in New Delhi as news of the verdict spread.

“I am speechless! It’s taken a long time to come but finally I can say I am free and I have equal rights as others,” said Rama Vij, a college student in Kolkata who gathered with others watching on television. The United Nations praised the activists who led the campaign.

“Today is a day of gay pride, a day of celebration, a day when respect and dignity was finally restored in India for lesbian, gay, bisexual, transgender and intersex people,” said Michel Sidibé, executive director of UN AIDS.

“I applaud the brave activists, civil society organizations and community groups that have fought long and hard for this injustice to be reversed.”

Despite the pressure on the LGBT community, India has quietly made some strides in sexual rights in recent years.

A transgender judge, Joyita Mondal Mahi, presides over courts in West Bengal state, Indian passports now state whether a holder is “male”, “female” or “other”, and the city of Raigarh, with 139,000 people, has a transgender mayor.

Campaigner Suri’s hotels are known for their gay-friendly discos and more professionals are coming out to challenge the Indian establishment.

Many say that gay marriage and equal rights in inheritance and other areas must be the ultimate prize, but they acknowledge that change will not be swift.

“This is the first step of the history of a lot of other countries that first decriminalised gay sex, allowed civil unions and then marriage,” said Suri.