Updated

New Delhi's gay community celebrated a landmark court ruling decriminalizing homosexuality — a decision that could end widespread police harassment and be a harbinger for gradual acceptance of homosexuals across this deeply conservative country.

The Delhi High Court ruled Thursday that treating consensual gay sex between adults as a crime is a violation of fundamental rights protected by India's constitution. The ruling, the first of its kind in India, is not binding outside New Delhi.

Hours after the ruling was issued dozens of members of New Delhi's gay community — some with rainbows painted on their faces and others holding signs that read "Queer and loving it" — gathered in the heart of the capital to celebrate.

"I'm so excited and I haven't been able to process the news yet," said Anjali Gopalan, the executive director of the Naz Foundation (India) Trust, the sexual health organization that filed the petition with the court.

"We've finally entered the 21st century."

But some religious leaders quickly criticized the ruling. "This Western culture cannot be permitted in our country," said Maulana Khalid Rashid Farangi Mahali, a leading Muslim cleric in the northern city of Lucknow.

Sex between people of the same gender has been illegal in India since a British colonial era law was issued in the 1860s classifying it as "against the order of nature." According to the law, gay sex is punishable by 10 years in prison.

While actual criminal prosecutions are few, the law frequently has been used to harass people. The court's verdict should protect New Delhi's gay community from criminal charges and police harassment.

"This legal remnant of British colonialism has been used to deprive people of their basic rights for too long," Scott Long, director of the Lesbian, Gay, Bisexual, and Transgender (LGBT) Rights Program at Human Rights Watch, said in a statement. "This long-awaited decision testifies to the reach of democracy and rights in India."

The verdict came more than eight years after the New Delhi-based Naz Foundation filed its petition — not unusually long in India's notoriously clogged court system. The decision can still be challenged in India's Supreme Court.

The government has remained vague about its position on the law, and Law Minister M. Veerappa Moily said he would examine the high court's order before commenting.

Anand Grover, a member of a lawyers group involved in the case, said in Geneva that groups besides the government might appeal to the Supreme Court.

While the ruling is not binding in India's other states, Naz Foundation lawyer Tripti Tandon said she hoped it would have a "persuasive" effect on other courts.

Rights activists say the law, also popularly known as 377, or section 377 of the Indian Penal Code, sanctions discrimination and marginalizes the gay community. Health experts say the law discourages safe sex and has been a hurdle in fighting HIV and AIDS. Roughly 2.5 million Indians have HIV.

The U.N. agency UNAIDS welcomed the court ruling and said it would make it easier to reach homosexual men with programs to combat the spread of HIV.

Homosexuality is slowly gaining acceptance in some parts of India, especially in its big cities. Many bars have gay nights, and some high-profile Bollywood films have dealt with gay issues. The last two years have also seen large gay pride parades in New Delhi and other big cities such as Mumbai and Calcutta.

Still, being gay remains deeply taboo in most of the country, and many homosexuals hide their sexual orientation from friends and families.

Religious leaders in the capital and in other parts of India argue that gay sex should remain illegal and that open homosexuality is out of step with India's deeply held traditions.

"We are totally against such a practice as it is not our tradition or culture," said Puroshattam Narain Singh, an official of the Vishwa Hindu Parishad, or World Hindu Council.

In New Delhi, Rev. Babu Joseph, a spokesman of the Roman Catholic church, told New Delhi Television that while homosexuals should not be treated as criminals, "at the same time we cannot afford to endorse homosexual behavior as normal and socially acceptable."

Still, rights activists hope that Thursday's ruling will send a message to the entire country.

"The symbolic value of this judgment is unmatched," said Arvind Narrain, another lawyer involved with the case. "It says lesbians, gays, bisexuals and transgender people are citizens with equal rights."