"We have to bid adieu to prejudices and empower all citizens," said Chief Justice Misra, reading out what he said was a consensus judgment. The judges also said: "Any discrimination on the basis of sexuality amounts to a violation of fundamental rights".

They also said that "consensual carnal intercourse among adults, be it homosexual or heterosexual, in private space, does not in any way harm the public decency or morality".

Section 377, which is part of an 1861 law, banned "carnal intercourse against the order of nature with any man, woman or animal" -- which was interpreted to refer to homosexual sex.

A part of that law still remains; non-consensual or consent obtained by force continues to be an offence, as will "carnal intercourse with children, animals and bestiality".

The verdict is being cheered by millions across the country, far beyond the gay community, which has fought for decades for the right to be treated equally.

The historic judgment acknowledged their struggle as it noted "158 years ago, the law deprived people of love." The judges said: "Respect for individual choice is the essence of liberty; LGBT community possesses equal rights under the constitution."

The ban on gay sex was challenged by five high-profile petitioners -- from a classical dancer to a celebrity chef and a hotel chain owner -- who said they were living in fear of being punished.

The petitions were opposed by Christian bodies like the Apostolic Alliance of Churches and Utkal Christian Association, besides some other NGOs and individuals.

The homosexual community had a five-year reprieve after the Delhi High Court in 2009 described Section 377 as a violation of the fundamental rights guaranteed by the constitution and removed the ban. It had responded to a petition by Naz Foundation, which has fought for almost a decade for gay rights.