The Supreme Court of India ruled in favor of a Hindu temple for religiously disputed reasons and ordered that Muslims be provided with alternative land for the construction of a mosque.
The dispute over land ownership was one of the country's most contentious issues.
The 16th-century Babri Masjid Mosque in the northern Indian city of Ayodhya in the state of Uttar Pradesh was destroyed in December 1992 by Hindu hardliners.
Five Supreme Court judges unanimously declared that five acres of land would be allocated to the Muslim community in a prominent location for the construction of a mosque. The controversial land will be handed over to a board of trustees for the construction of a temple for the Hindu god Ram.
Hindu devotees and activists celebrated the verdict on the courts' courtyards, blaring horns and singing "Jai Shree Ram" or praising the god Ram.
A lawyer representing the Muslims regretted the verdict.
"We are not satisfied with the verdict and it does not meet our expectations," said Zafaryab Jilani, who represents the Babri Action Committee of the Muslim community.
"These five acres of land mean nothing to us, we examine the verdict and whatever legal means we have."
He pointed out that he would file a petition for review with the Supreme Court against Saturday's ruling. At the same time, he appealed to members of all communities to uphold the peace.
Vishnu Shankar Jain, a lawyer representing the Hindu community, said the trip over several years had been a struggle.
"It was a huge legal dispute and we are pleased that we have convinced the Supreme Court. It's a historic moment for Hindus, "he said.
Raj Nath Singh, India's defense minister, appealed to all to "accept the court verdict and maintain peace".
In Islamabad, Pakistani Foreign Minister Shah Mahmood Qureshi criticized the verdict and said it shows the "hate-based thinking" of Indian Prime Minister Narendra Modi's government.
"This is none other than Modi's policy of cultivating hatred and promoting differences between communities and religious communities in order to achieve their goals," he said.
Hindu hardliners say they want to build a new temple for God Ram, whom they worship as their birthplace. They say the mosque was built after a temple dedicated to the Hindu god was destroyed by Muslim invaders.
Following the demolition of the mosque, Hindus and Muslims have brought the case to a lower court, which decided in 2010 that the disputed land should be divided into three parts – two for Hindus and one for Muslims.
This was challenged by both communities before the Supreme Court.
The five judges instituted a daily trial in August after the mediation had failed to reach a compromise.
Mr. Modi had promised to build the temple in the 2014 election that brought him to power. Later, however, despite the pressure of millions of Hindu hardliners who urged his government to enact laws for the construction of the temple, he decided to wait for the court verdict.
The authorities increased security in Ayodhya, 350 miles east of New Delhi, and deployed more than 5,000 paramilitary forces to prevent attacks by Hindu activists on Muslims, who make up 6% of the city's 55,500 residents.
Among the strict measures was the ban on the assembly of more than four people in one place.