"It is necessary to provide restitution to the Muslim community for the unlawful destruction of their place of worship," it stated.
The apex court gave the Centre three months' time to formulate a scheme to set up a trust which will helm the construction of a temple at the site.
"The Central Government shall make necessary provisions in regard to functioning of trust or body including on matters relating to management of the trust, powers of the trustees including the construction of a temple," the judgment stated.
The bench also comprising Justices SA Bobde, DY Chandrachud, Ashok Bhushan and S Abdul Nazeer passed the order on a batch of petitions against an order of the Allahabad High Court which trifurcated the site between the parties - Ramlalla Virajman, Sunni Central Waqf Board and Nirmohi Akhara.
A decades-long legal dispute was fought by Hindu Mahasabha, a sect of Hindu monks Nirmohi Akhara and Muslim Waqf Board over 2.77 acres of land in Ayodhya.
The hearing which went on for 40-days saw the bench hearing appeals against an order of the Allahabad High Court which trifurcated the site between the three parties.
The site, where Babri Masjid built by Mughal emperor Babur once stood, was split into equal portions, effectively handing out one part to Muslims and two parts to the Hindus.
The legal battle between the two parties dates back to the British era. The first appeal was, however, filed in 1950.