India's Supreme Court has refused to hear a petition challenging a law criminalising gay sex, a setback for gay rights activists battling in the country's courts to get the ban overturned.

A number of well-known lesbian, gay and bisexual Indians had argued that Section 377 of India's penal code, which prohibits "carnal intercourse against the order of nature with any man, woman or animal", undermined their fundamental rights by failing to protect their sexual preferences.

"The Supreme Court refused to hear the matter and asked the petitioners to approach the Chief Justice of India," Arvind Dattar, a lawyer for one of the petitioners, said.

India's chief justice is already hearing a separate case to strike down the ban, and India's top court has previously argued that only Parliament has the power to change Section 377.

The decision is the latest setback India's gay community has faced in its fight to get a prohibition on homosexual sex overturned ever since the Supreme Court reinstated a colonial-era ban in late 2013.

That ban ended a four-year period of decriminalisation that had helped bring homosexuality increasingly out into the open in a deeply conservative society.

Discrimination faced by homosexual communities across the world was thrown into sharp relief again this month after a gunman slaughtered 49 people at a gay nightclub in Florida.

Some Western countries have pressured India to overturn its ban on gay sex and respect human rights regardless of sexual orientation.

This month US Ambassador Richard Verma's residence in New Delhi's leafy diplomatic quarter was lit in the colours of the rainbow in a gesture of solidarity towards victims of the Orlando massacre.

Violation of the Indian law on gay sex can result in a prison sentence of up to 10 years.

Reuters