An Indian court has, for the first time ever, appointed itself the legal guardian of millions of cows in a move to protect the animals considered sacred to the country’s majority Hindu community.

The Uttarakhand High Court not only banned the slaughter of all cattle in the mountainous state 240 miles north of New Delhi, but also the sale and consumption of beef.

The move follows similar protections rolled out by state governments following the election of Prime Minister Narendra Modi’s Hindu nationalist Bharatiya Janata Party (BJP), which holds staunchly traditional views on cattle. This is the first time, however, that a court has taken the initiative.

Citing ancient Hindu and Buddhist scriptures, which propagated cow protection, the judges threatened prosecution for anyone abandoning or maltreating their cattle and ordered the appointment of mobile infirmaries within three weeks.

The judges also ordered shelters for the animals to be set up for every cluster of 25 villages in a response to a petition by a local farmer claiming that waste from slaughtered cattle was contaminating the local water supply.