The high court in Himachal Pradesh has asked police and other officials to enforce its ban on the slaughter, mainly of goats in Hindu temples throughout the state.
"No person will sacrifice any animal in any place of worship. It includes adjoining lands and buildings," the two-judge bench of the court ruled late on Monday.
"A startling revelation has been made … thousands of animals are sacrificed every year in the name of worship," the court said.
"Sacrifice causes immense pain and suffering to innocent animals. They cannot be permitted to be sacrificed to appease a god or deity in a barbaric manner," it said.
The court also questioned the reasons for animal sacrifices, saying such rituals "must change in the modern era".
The court was ruling on a petition brought by animal rights activists, who applauded the move on Tuesday as long overdue.
"We welcome this ban on animal sacrifice as it will end centuries of cruelty to animals in the name of religion," local activist Rajeshwar Negi told AFP.
But state lawmaker Maheshwar Singh defended the practice, saying: "This judgment is against the age-old beliefs and customs of many people."
Goats and sometimes sheep are often sacrificed at the start of winter in temples across Himachal Pradesh with the aim of pleasing Hindu deities.
Animals are symbolically offered to the deity and later taken home by villagers and their guests for eating during the Himalayan state's bitterly cold winter.
Some of the sacrifices at festivals, including those of "shaand" and "bhunda", involve large numbers of animals killed using a knife at the entrance of the temples.