NEW DELHI — India’s Supreme Court ruled that a Hindu temple could be built at the site of a razed mosque in a historic verdict on a dispute that has roiled the country for decades.

The verdict awarded the land at the heart of the clash to a Hindu litigant over Muslim objections and represents a major victory for Prime Minister Narendra Modi.

The building of a temple to the Hindu god Ram in the town of Ayodhya is a long-cherished goal of Hindu nationalists and a key objective of India’s ruling Bharatiya Janata Party.

Modi won reelection in a landslide in May and has moved swiftly to implement his agenda. To Modi and his party, India is fundamentally a Hindu nation, not the secular republic promoted by the country’s founders.

On Saturday, Modi hailed the ruling and called for calm. “This verdict shouldn’t be seen as a win or loss for anybody,” he wrote on Twitter. “The halls of justice have amicably concluded a matter going on for decades.”

In this country of more than 1.3 billion people, there is no issue quite like the controversy over Ayodhya, which has provoked violence and inflamed communal tensions for years.

For many Hindus, the disputed site is revered as the spot where Ram, a beloved god and avatar of Vishnu, was born. Some believe a Hindu temple once stood there and was later torn down by India’s Muslim rulers.

In the 16th century, the Babri mosque was built at the same location. In 1992, Hindu extremists attacked and illegally destroyed the mosque. The razing of the structure set off deadly communal riots across the country that killed about 2,000 people.

Now Saturday’s unanimous verdict by the Supreme Court sets the stage for the construction of a grand Hindu temple at the site. The judges upheld the claim of one of the Hindu petitioners to the land at the center of the dispute — less than three acres in size — and ordered it be held in a trust overseen by the government. At the same time, it granted five acres of land at an alternative location to Muslim litigants.

Ahead of Saturday’s verdict, authorities beefed up security precautions across the country in anticipation of possible unrest. In India’s largest state, Uttar Pradesh, schools were shut through Monday. Restrictions on public gatherings were implemented in Delhi and Mumbai, India’s two largest cities, according to local news reports.

There were no reports of unrest or clashes as of Saturday evening. In Ayodhya, thousands of pilgrims left the town in a panic late Friday after they learned the verdict was imminent, fearing potential violence. But on Saturday, the atmosphere was alert yet peaceful. There was a heavy security presence on the streets, with barricades on roads and certain restrictions on movement.

Muslim leaders called for calm on Saturday. Lawyers for the Muslim parties in the case said they would reject the grant of the five acres of land and ask the court to review its decision, but it is highly unlikely the ruling will be overturned.

The verdict “puts the government in the driver’s seat” when it comes to building a temple, said Nizam Pasha, a lawyer for the Muslim parties in the case. He said the judges had tried very hard to keep the messaging positive in their ruling but had used acrobatics of reasoning to reach their conclusions.

In their ruling, the judges said they were “tasked with the resolution of a dispute whose origins are as old as the idea of India itself.” They stressed India’s commitment to secularism and affirmed that both Hindus and Muslims had used the site as a spot of worship.

Their final reckoning, however, awarded the title to the disputed land to a Hindu litigant representing the god Ram himself. (In Indian jurisprudence, a god can be considered a legal entity.)

Dhirendra Jha, the author of a book on the Ayodhya dispute, said he expected the government to move quickly to begin the process of building the temple.

“I don’t think it will take much time. The government, the ruling party and their parent organization are all on the same page,” he said, referring to the Rashtriya Swayamsevak Sangh, or RSS, a powerful right-wing Hindu nationalist group that is the progenitor of the current ruling party.

On Saturday, Mohan Bhagwat, the RSS chief, praised the Supreme Court ruling. “We thank and congratulate the judges,” he told reporters. “We will forget everything that has happened in the past and will construct a grand temple of Lord Ram.”

In Ayodhya, where the dispute has shadowed the lives of residents for decades, there was a sense that the ruling would deliver some finality after years of controversy. Iqbal Ansari, 53, one of the Muslim petitioners in the case, said he welcomed the verdict. “This is the decision that I and every Muslim of Ayodhya was expecting, and I am not going to challenge it again,” he said.

Achal Kumar Gupta, 45, runs a restaurant close to the disputed site and said he applauded the ruling. Now the “uneasy calm” that had prevailed in the town would end, he said. “If the land would have been divided between the communities, then it would have resulted in simmering tensions between Hindus and Muslims.”

The site in Ayodhya has been the subject of a legal battle dating back to the 1950s. In 2010, an appeals court in Uttar Pradesh issued a verdict splitting the land three ways between two Hindu groups and one Muslim group — a ruling rejected by all parties.

Attempts to mediate the dispute failed, and in August, the Supreme Court began 40 days of hearings to reach a judgment.

After the verdict was announced Saturday, shouts of “Jai Shri Ram!” — victory to Lord Ram — and “We will build a temple there!” erupted outside the Supreme Court. Some blew conch shells, a traditional Hindu signal of triumph.

Saurabh Sharma in Ayodhya, India, and Tania Dutta in New Delhi contributed to this report.