The verdict in the decades-old dispute is a big victory for Prime Minister Narendra Modi, who won re-election in a landslide in May. The construction of a temple to the Hindu god Ram is a long-standing goal for India's ruling Bharatiya Janata Party.
In 1992, Hindu extremists demolished a 16th-century mosque in Ayodhya to make way for the temple, an act that initiated deadly communal riots across the country. Hindu nationalist groups believe that the mosque was built at the site of Ram's birthplace where a Hindu temple once stood.
Before Saturday's ruling, the authorities made better security measures throughout the country. In India's largest state, Uttar Pradesh, schools were closed pending any concerns. Restrictions on public gatherings were implemented in Delhi and Mumbai, India's two largest cities, according to local news reports.
Modi appealed calmly the night before the verdict. "We have to maintain harmony together," he wrote on Twitter . "Any decision on Ayodhya coming from the Supreme Court, it will not be anyone's defeat or victory."
Outside the Supreme Court on Saturday shouted "Jai Shri Ram!" – victory to Lord Ram – and "We will build a temple there! "Broke out after the verdict was announced. Some blew seashells, a traditional Hindu signal of triumph.
Tania Dutta contributed reporting.