A separate piece of land in Ayodhya would be given to Muslim groups to build a new mosque
India's top court handed on Saturday a huge victory to Prime Minister Narendra Modi's Hindu nationalist ruling party by awarding Hindus control of a bitterly disputed holy site that has sparked deadly sectarian violence.
India had stepped up security nationwide ahead of the decision and Modi called for calm, fearing the final ruling on an issue that has been a focal point of Hindu-Muslim tensions for decades could again trigger unrest.
The Supreme Court ruled that the site in Ayodhya in northern India, where Hindu mobs destroyed a 460-year-old mosque in 1992, must be handed over to a trust to oversee the construction of a Hindu temple, subject to conditions.
A separate piece of land in Ayodhya would be given over to Muslim groups to build a new mosque, the court ruled in a historic judgement aimed at ending a bitter and legal wrangle dating back decades.
Thousands of extra personnel including riot police were deployed and schools closed in and around the northern city of Ayodhya, centre of the thorny dispute, and elsewhere.
In Ayodhya gatherings of people were banned and barricades were erected on roads leading to the Supreme Court building in New Delhi with officials and volunteers scouring social media for inflammatory posts in Facebook's biggest market.
Hardliners among India's majority Hindus, including supporters of Modi's Hindu nationalist Bharatiya Janata Party (BJP), believe that Lord Ram, the warrior god, was born in Ayodhya some 7,000 years ago.
They say that in the 16th century, Babur, the first emperor of the Mughal Islamic dynasty, built a mosque on top of a temple at the 2.8-acre site.
In the 1980s, as Hindu nationalism and the BJP began to strengthen, pressure grew for the mosque to be knocked down and replaced by a glorious Hindu temple.
In 1992, a Hindu mob estimated to number 200,000 did just that, reducing the mosque to rubble.
This unleashed some of the worst religious riots since India's bloody partition at the end of British colonial rule in 1947, leaving around 2,000 people dead, mainly Muslims.
Ten years later in 2002, after 59 Hindu activists died in a blaze on a train from Ayodhya, riots in Gujarat state - when Modi was its chief minister - saw upwards of 1,000 people perish, again largely Muslims.
According to media reports, the court ruled that archaeological evidence indicated that there was a structure built before the mosque at the site "of Hindu origin."
The verdict, it is hoped, will put an end to an angry and at times arcane legal wrangle that British colonial rulers and even the Dalai Lama tried to mediate.
Zafaryab Jilani, a lawyer representing one of the Muslim litigants, said however that the verdict was "unjust" and that he was considering filing a review.
Varun Kumar Sinha, a lawyer representing one of the Hindu groups, said: "It is a historic judgement. With this judgement, the Supreme Court has given the message of unity in diversity."
The case also involved a nonagenarian lawyer representing a Hindu deity and has seen a high drama including a lawyer representing Muslim groups tearing a purported ancient map showing the temple.
Victory for Modi
The BJP has campaigned for years for a temple to be built at Ayodhya, and the verdict is a major victory for the party, just months into Modi's second term.
But it will also send shudders through many in the 200-million-strong Muslim minority.
The BJP owes its origins to Rashtriya Swayamsevak Sangh (RSS), a militaristic group that has long espoused "Hindutva", or Hindu hegemony, and making India an exclusively Hindu state.
Under Modi, several cities with names rooted in India's Mughal past have been re-named, while some school textbooks have been changed to downplay Muslims' contributions to India.
A string of lynchings of Muslims by Hindu mobs over so-called cow protection - a sacred animal for many Hindus -- and other hate crimes has sown fear and despair in the community.
This year New Delhi stripped Jammu and Kashmir, India's only Muslim-majority state, of its autonomy.
Modi is nevertheless desperate to avoid bloodshed and ahead of the4 verdict, the BJP and the RSS have told supporters before the verdict to avoid any provocative celebrations.
Muslim groups have also appealed for calm.
"Whatever is the verdict by the Supreme Court, it won't be anybody's win or loss," Modi tweeted late Friday.
"My appeal to the people of India is that our priority is to ensure the verdict strengthens the values of peace, equality and goodwill of our country."