Justices G S Singhvi and S J Mukhopadhyay, however, added that the government was free to amend Section 377 of IPC (unnatural sex), if it desires.
The bench also told the government that while amending the law it must consult the Attorney General of India.
Delivering the landmark judgement, the apex court set aside the verdict by the Delhi High Court which had decriminalised gay sex between two consenting adults in secrecy.
The Supreme Court also blamed the government and LGBT activists for the present situation, saying that the court cannot strike down the law.
It asked the government why it did not proceed to amend the law, namely Sec 377 of IPC, for so many years.
The apex court also added that activists never pleaded for striking down the concerned section and the future of law and LGBT is in the hands of the legislature.
The High Court judgement that decriminalised gay sex was challenged by a number of religious and social organisations as well as eminent persons including former DGP of UP BP Singhal, yoga guru Baba Ramdev, his media aide S K Tijarawala as well as a astrologer Suresh Kaushal.
Justice Singhvi delivered the judgement on his last working day in the Supreme Court.
‘’People criticising the judgement should go through it,’’ he added.
The Delhi High Court had delvered the ruling on a petition of the NGO Naz Foundation.
It was challenged in the apex court on the grounds that gay sex violated the laws of nature and was contrary to the cultural ethos of the country.