An Indian court today decriminalised homosexuality – but only in the country's capital, Delhi.

The Delhi high court ruled that treating consensual gay sex as a crime was a violation of fundamental rights protected by India's constitution.

The ruling is the first of its kind in the deeply conservative country.

"We've finally entered the 21st century," said Anjali Gopalan, the executive director of the Naz Foundation (India) Trust, a sexual health organisation that filed a petition calling for decriminalisation eight years ago.

The verdict can be challenged in India's supreme court.

Sex between people of the same gender has been illegal in India since a British colonial era law classified 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 legislation has frequently been used to harass people.

It can only be amended by the Indian parliament, but the court's verdict should protect Delhi's gay community from criminal charges and police harassment.

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

Rights activists say the law against sex between people of the same gender sanctions discrimination and marginalises the gay community.

Health experts say it also discourages safe sex and has been a hurdle in fighting HIV and Aids. Around 2.5 million Indians have HIV.

Homosexuality is slowly gaining acceptance in some parts of India, especially in the big cities. Many bars have gay nights, and some high-profile Bollywood films have had gay themes.

Nevertheless, being gay remains deeply taboo, and many homosexuals hide their sexual orientation from their friends and families.

Supporters of the law – including the leaders of conservative Hindu political and religious groups – argue that gay sex should remain illegal and that open homosexuality is out of step with India's traditions.