The ruling in the dispute between Hindu and Muslim groups paves the way for the construction of a Hindu temple on the site in the northern town of Ayodhya, a proposal long supported by Prime Minister Narendra Modi’s ruling Hindu-nationalist party.
Representatives of the Muslim group involved in the case criticized the judgment as unfair and said it was likely to seek a review of the verdict.
In 1992 a Hindu mob destroyed the 16th-century Babri Mosque on the site, triggering riots in which about 2,000 people, most of them Muslims, were killed across the country.
Court battles over the ownership of the site followed.
Jubilant Hindus, who have long campaigned for a temple to be built on the ruins of the mosque, set off fire crackers in celebration in Ayodhya, Reuters reported.
Thousands of paramilitary force members and police were deployed in Ayodhya and other sensitive areas across India and there were no immediate reports of unrest.
“This verdict shouldn’t be seen as a win or loss for anybody,” Prime Minister Narendra Modi said on Twitter.
“May peace and harmony prevail!”
Still, the verdict is likely to be viewed as win for the Modi’s ruling Bharatiya Janata Party (BJP) and its backers.
It comes months after Modi’s government stripped the Muslim-majority Jammu and Kashmir region of its special status as a state, delivering on yet another election promise to its largely Hindu support base.
Neelanjan Sircar, an assistant professor at Ashoka University near New Delhi, said the court ruling would benefit the BJP, which won re-election in May, but a slowing economy would ultimately take center stage for voters.
“In the short term, there will be a boost for the BJP,” said Sircar. “These things don’t work forever ... Ram Temple isn’t going to put food on the table.”
Hindus believe the site is the birthplace of Lord Ram, a physical incarnation of the Hindu god Vishnu, and say the site was holy for Hindus long before the Muslim Mughals, India’s most prominent Islamic rulers, built the Babri mosque there in 1528.
The five-judge bench, headed by the Chief Justice Ranjan Gogoi, reached a unanimous judgment to hand over the plot of just 2.77 acres (1.1 hectares), or about the size of a soccer field, to the Hindu group.
The court also directed that another plot of 5 acres (2 hectare) in Ayodhya be provided to the Muslim group that contested the case.
Modi’s party hailed the ruling as a “milestone.”
“I welcome the court decision and appeal to all religious groups to accept the decision,” Home Minister Amit Shah, who is also president of the BJP, said on Twitter.
The Sunni Muslim group involved in the case said it would likely file a review petition, which could trigger another protracted legal battle.
“This is not a justice,” said the group’s lawyer, Zafaryab Jilani.
Muslim organizations appealed for calm.
The Hindu group Rashtriya Swayamsevak Sangh - the parent organization of Modi’s party - had already decided against any celebrations to avoid provoking sectarian violence between India’s majority Hindus and Muslims, who constitute 14% of its 1.3 billion people.
Restrictions were placed on gatherings in some places and internet services were suspended. Elsewhere, police monitored social media to curb rumors.
Streets in Ayodhya were largely deserted and security personnel patrolled the main road to Lucknow, the capital of the northern state of Uttar Pradesh.
Ayodhya residents were glued to their televisions and mobile phones for news of the ruling, which delighted Hindus when it came.
“Everyone should come together to ensure that the construction work begins at the site without any delay,” roadside vendor Jitan Singh said over the chants of “Jai Shri Ram” (hail Lord Ram) from fellow shop-keepers.