INDIA'S Supreme Court has reinstated a ban on gay sex in the world's largest democracy, following a four-year period of decriminalisation that had helped bring homosexuality into the open.

In 2009 the Delhi High Court ruled unconstitutional a section of the penal code dating back to 1860 that prohibits "carnal intercourse against the order of nature with any man, woman or animal" and lifted the ban for consenting adults.

The Supreme Court threw out that decision, saying only parliament could change Section 377 of the penal code, widely interpreted to refer to homosexual sex. Violation of the law can be punished with up to 10 years in jail.

The move shocked rights activists around the world, who had expected the court simply to rubber-stamp the earlier ruling. In recent years, India's Supreme Court has made progressive rulings on several issues such as prisoners' rights and child labour.

"It's a black day for us," said Anjali Gopalan, the executive director of the Naz Foundation, a Delhi-based NGO that works on sexual health and led the consortium of advocacy groups defending the 2009 judgment.

"I feel exhausted, thinking we have been set back by 100 years."

US actress Mia Farrow described the decision as "a very dark day for freedom and human rights," in a post on Twitter.

India's law minister Kapil Sibal said the government could raise the matter in parliament. Prime Minister Manmohan Singh's government was seen to broadly support the 2009 ruling, and some ministers said they opposed yesterday's court decision.

But it seems unlikely the government will risk taking a stand on the issue in the short term. General elections are due by next May and the socially conservative Hindu nationalist opposition is already gathering momentum.

India's gay culture has opened up in recent years, although the country remains overwhelmingly conservative and sex outside marriage, even among heterosexual couples, is largely frowned upon. India's first gay pride march took place in the eastern city of Kolkata in 1999 and only around a dozen people attended.

Yet, since 2008, India's capital Delhi, its financial centre, Mumbai, the IT hub of Bangalore and other cities have started holding much larger events. Gay film festivals and university campus groups have also sprung up.

Gay rights activists have also long argued the current law reflects British colonial standards of morality and not Indian traditions.