The disputed holy site of Ayodhya in northern India should be given to Hindus who want a temple built there, the country’s Supreme Court has ruled.
The case, which has been bitterly contested for decades by Hindus and Muslims, centres on the ownership of the land in Uttar Pradesh state.
Muslims would get another plot of land to construct a mosque, the court said.
Many Hindus believe the site is the birthplace of one of their most revered deities, Lord Ram.
Muslims say they have worshipped there for generations.
At the centre of the row is the 16th Century Babri mosque that was demolished by Hindu mobs in 1992, sparking riots that killed nearly 2,000 people.
In the unanimous verdict, the court said that a report by the Archaeological Survey of India (ASI) provided evidence that the remains of a temple existed beneath the structure of the demolished Babri mosque.
It said that given all the evidence before it, the court had determined that the disputed land should be given to Hindus, while Muslims would be given land elsewhere to construct a mosque.
It then directed the federal government to set up a trust to manage and oversee the construction of the temple.
However, the court added that the demolition of the Babri mosque was against the rule of law.
Despite warnings by authorities not to celebrate the verdict, BBC correspondents in court say they heard chants of “Jai Shree Ram” (Hail Lord Ram) outside as the judgement was pronounced.
“It’s a very balanced judgement and it is a victory for people of India,” a lawyer for one of the Hindu parties told reporters soon after.
However, a representative for the Muslim litigants said that they were not satisfied and would decide whether to ask for a review after they had read the whole judgement.
Outside the court, the situation has been largely calm.
Hundreds of people were detained in Ayodhya on Friday ahead of the verdict, amid fears of violence.
Thousands of police personnel have also been deployed in the city, and shops and colleges have been shut until Monday.
Social media platforms are being monitored for inflammatory content, with police even replying to tweets and asking users to delete them.
Prime Minister Narendra Modi and other political leaders have appealed for calm.