Advocates of the ban argued that it should be respected because it had been in effect for so long, and that the temple’s celibate deity had constitutional rights. But in a 4 to 1 decision, the court disagreed. “Religion cannot become a cover to exclude and to deny the right of every woman to find fulfillment in worship,” Judge Dhananjaya Y. Chandrachud wrote in his opinion.

Almost immediately, thousands of protesters who disagreed marched in Kerala, threatening violent repercussions for women who tried to visit the temple.

Bhakti Pasrija Sethi, a lawyer who was involved in challenging the ban, said she was baffled by the backlash, saying the dismantling of exclusionary rules in other places of worship, like the Haji Ali, a mosque and tomb in Mumbai, or temples in west central India, were not met with the same level of vitriol.

In any case, she said, there was evidence that women had peacefully visited the Sabarimala Temple decades ago for rice-feeding ceremonies, which mark a baby’s first intake of solid foods. Other temples dedicated to Lord Ayyappa also allow women to enter, she said.

“They are giving superstition the cover of religion,” Ms. Sethi said of the protesters. “What they are doing is not religion. The Hindu religion is not teaching you violence.”

Kerala’s chief minister, Pinarayi Vijayan, attributed much of the chaos to members of fringe Hindu groups disguising themselves as pilgrims and then “spreading terror.” Kerala is run by a coalition of communist parties; opposition politicians in the state have warned the police not to use force against protesters and argued that India’s central government, which is led by a party with Hindu nationalist roots, should take over security at the temple.