India's top court has upheld a law which criminalises gay sex, in a ruling seen as a major blow to gay rights.
The Supreme Court ruling reverses a landmark 2009 Delhi High Court order which had decriminalised homosexual acts.
The court said it was up to parliament to legislate on the issue.
According to Section 377, a 153-year-old colonial-era law, a same-sex relationship is an "unnatural offence" and punishable by a 10-year jail term.
Several political, social and religious groups had petitioned the Supreme Court to have the law reinstated in the wake of the 2009 court ruling.
Correspondents say although the law has rarely - if ever - been used to prosecute anyone for consensual sex, it has often been used by the police to harass homosexuals.
Also, in deeply conservative India, homosexuality is a taboo and many people still regard same-sex relationships as illegitimate.
The BBC's Sanjoy Majumder in Delhi says some politicians have spoken out against the court decision - but many believe it is going to be difficult for them to take on the anti-gay lobby.
"It is up to parliament to legislate on this issue," Justice GS Singhvi, the head of the two-judge Supreme Court bench, said in Wednesday's ruling, which came on his last day before retiring.
"The legislature must consider deleting this provision (Section 377) from law as per the recommendations of the attorney general," he added.
India's Law Minister Kapil Sibal told reporters the government would respect the ruling but did not say whether there were plans to amend the law. Correspondents say any new legislation is unlikely soon - general elections are due next year.
Gay rights activists have described Wednesday's Supreme Court ruling as "disappointing" and said they would approach the court to review its decision.
"Such a decision was totally unexpected from the top court. It is a black day," Arvind Narrain, a lawyer for the Alternative Law Forum gay rights group, told reporters.
"We are very angry about this regressive decision of the court," he said.
"This decision is a body-blow to people's rights to equality, privacy and dignity," G Ananthapadmanabhan of Amnesty International India said in a statement.
"It is hard not to feel let down by this judgement, which has taken India back several years in its commitment to protect basic rights," he added.
However, the ruling has been welcomed by religious groups, particularly leaders of India's Muslim and Christian communities, who had challenged the Delhi High Court order.
"The Supreme Court has upheld the century-old traditions of India, the court is not suppressing any citizen, instead it is understanding the beliefs and values of the large majority of the country," Zafaryab Jilani, member of the All India Muslim Personal Law Board, told BBC Hindi.
In its 2009 ruling, the Delhi High Court had described Section 377 as discriminatory and said gay sex between consenting adults should not be treated as a crime.
The ruling was widely and visibly welcomed by India's gay community, which said the judgement would help protect them from harassment and persecution.