Members of the LGBT community in India dance to celebrate after the country’s top court struck down a colonial-era law that made homosexual acts punishable with a prison sentence of 10 years-to-life. (AP Photo/Aijaz Rahi)

India’s top court on Thursday overruled a previous decision, striking down a 157-year-old law that criminalized gay sex.

A five-judge bench of the Supreme Court of India unanimously ruled that Section 377 of the Indian Penal Code, which punished gay sex with a 10-year-to-life sentence, was unconstitutional. The decision, which emphasized inclusion and diversity in society, was a landmark win for LGBT rights in India, which has the world’s second-largest population.

“The ideals and objectives enshrined in our benevolent constitution can be achieved only when each and every individual is empowered and enabled to participate in the social mainstream and in the journey towards achieving equality in all spheres, equality of opportunities in all walks of life, equal freedoms and rights and, above all, equitable justice,” wrote Chief Justice Dipak Misra, in the majority opinion of the case.

“This can be achieved only by inclusion of all and exclusion of none from the mainstream.”

The origin of the case dates back nearly two decades: in 2001, the NAZ Foundation, a nonprofit gay rights organization, sued to challenge the law written in 1860 during the British colonial era. In 2009, the Delhi High Court first ruled in a historic decision in favor of NAZ and declared the criminalization of consensual sexual acts between adults in private was a violation of personal liberty and equality under the Constitution of India.

A group of religious organizations then challenged the 2009 decision and in 2013, a two-judge bench of the Supreme Court reversed the decision and upheld Section 377 in Suresh Kumar Koushal and another v. Naz Foundation and others. In 2016, a group of LGBT activists led by choreographer Navtej Johar sued again to challenge Section 377 in the case known as Navtej Singh Johar v. Union of India.

In the most recent decision, Misra, who is due to retire in October, penned the majority opinion, which was joined by Justice A. M. Khanwilkar. Justices R. F. Nariman, D. Y. Chandrachud and Indu Malhotra each wrote a concurring opinion. All five judges were appointed to the Supreme Court after the 2013 Koushal decision.

The justices agreed that consensual sexual acts between adults and sexual orientation were part of a person’s privacy and that the right to privacy was a fundamental right under the country’s constitution. More importantly, the bench also held that LGBT people in India should enjoy equal constitutional rights and protection under the law, without discrimination.

“All human beings possess the equal right to be themselves instead of transitioning or conditioning themselves as per the perceived dogmatic notions of a group of people,” Misra wrote.

“Members of the LGBT community are entitled, as all other citizens, to the full range of constitutional rights including the liberties protected by the constitution,” wrote Chandrachud in his concurring opinion. “The choice of whom to partner, the ability to find fulfillment in sexual intimacies and the right not to be subjected to discriminatory behavior are intrinsic to the constitutional protection of sexual orientation.”

The justices also argued that the constitution should be able to adapt to the changing needs and demands of society and that the interpretation of the constitution’s provisions “should not be limited to the mere literal meaning of its words.

“Let us move from darkness to light, from bigotry to tolerance and from the winter of mere survival to the spring of life―as the herald of a New India―to a more inclusive society,” wrote the chief justice.

“This ruling is hugely significant,” Meenakshi Ganguly, the South Asia director for Human Rights Watch, told The New York Times. The ruling in India may encourage still more nations to act, she said.

The justices relied on a series of international case law, including the 2003 U.S. Supreme Court decision in Lawrence v. Texas, in which the court struck down similar laws criminalizing same-sex sexual activity in a 6-3 decision. Chandrachud also cited the decisions in United States v. Windsor and Obergefell v. Hodges—cases that expanded the court’s recognition of the constitutional rights of members of the LGBT community in civil union and marriage. Anthony Kennedy, who penned the majority opinions of all three cases, retired from the Supreme Court in July.

“The overwhelming weight of international opinion and the dramatic increase in the pace of recognition of fundamental rights for same-sex couples reflects a growing consensus towards sexual orientation equality,” Chandrachud wrote.

“Decriminalization is a first step. The constitutional principles on which it is based have application to a broader range of entitlements,” he continued. “The Indian Constitution is based on an abiding faith in those constitutional values. In the march of civilizations across the spectrum of a compassionate global order, India cannot be left behind.”