EDALPUR, India — Late last month, the government administrator who oversees this area of farmland in northern India was in a meeting when she received a strange phone call.

It was from a middle school principal in Edalpur, a village of 2,000 people surrounded by fields of wheat and potatoes. “There are cows locked in my school and a hundred people outside,” said the principal, Bani Singh. “What should I do?”

The next day, the administrator, Jyotsna Bandhu, received a similar phone call from a different village under her supervision. After that, she said, it spread like a “chain reaction.”

Before long, about 15 other nearby villages had reported the same phenomenon. Angry farmers locked hundreds of stray cows in public schools, turning them into animal sheds and issuing a challenge to the local government: Fix this.

In India, it is not unusual to see cattle roaming the roads of cities and towns. But across Uttar Pradesh, the country’s most populous and politically important state, frustration is boiling over among farmers, who say the number of stray cows has spiked, threatening their crops.

The dilemma — which the state government called a “burning issue” in a directive to bureaucrats this month — is part of India’s turn toward Hindu nationalism. Prime Minister Narendra Modi and his ruling Bharatiya Janata Party (BJP) have made protecting cows, considered sacred in Hinduism, a policy priority.

Students do calisthenics in the courtyard of a public school in Basdatta, India. Villagers locked dozens of stray cattle in the school last month. (Joanna Slater/The Washington Post)

In Uttar Pradesh, home to more than 200 million people, the drive to safeguard cows has had far-reaching effects. In 2017, Modi installed a radical Hindu monk, Yogi Adityanath, to lead the state. Adityanath launched a crackdown on unauthorized slaughterhouses and enforced regulations on the transportation and sale of cattle.

That all adds up to a quandary for farmers. When cows were too old to provide milk and bulls were no longer useful for hauling or generating progeny, many farmers used to sell them. Middlemen would transport cattle to other states or sometimes to slaughterhouses. Now those networks have collapsed. Farmers must either bear the expense of caring for unproductive cattle or simply abandon them. Increasingly, they are choosing the latter.

In Edalpur, stray cows went from an occasional irritation to a constant menace. This winter, farmers organized shifts to conduct all-night vigils in the cold, huddled in layers of clothing around small fires. Armed with sticks and flashlights, they watched for packs of stray cattle that would trample leafy potato plants and chomp on tender new wheat.

The tipping point came a couple of months ago, villagers said. A farmer attempting to roust stray cows from his field through the liberal use of a stick mistakenly landed a blow on his neighbor, whose head began bleeding. A fight ensued.

Stray cattle in a field of mustard plants in Hathras district in the Indian state of Uttar Pradesh. (Joanna Slater/The Washington Post)

No one in the village would say whose idea it was to round up the stray cows and lock them in the school. “When people get pushed so much beyond their limits, what will they do? They will come up with a solution,” said Chhetra Pal, 25, who grows millet. “The whole village agreed.”

In the village of Bedai in the same district, the middle school had just received a fresh coat of cheerful yellow paint when farmers pushed 200 cows into its gates on Dec. 31. The cattle stayed for four days, leaving the school walls splashed with mud and urine. The school remained closed through mid-January, and its 70-odd students were taught instead at a nearby elementary school.

It’s not clear how many stray cows there are in Uttar Pradesh: The last official count, in 2012, put the number at more than 1 million. The current state government has “disturbed the natural cycle” and left farmers with little choice but to abandon cows, said Anil Chaudhary, a former member of the state legislature from a regional party.

A state government minister said the challenge posed by stray cattle predated the current leadership. “This has been a problem, and it is our government which is trying to find a solution,” said S.P. Singh Baghel, the minister of animal husbandry in Uttar Pradesh. “We have just enforced the law.”

With national elections looming in the spring, the state government has swung into action to defuse an obvious political liability. Adityanath, the chief minister, announced a new 0.5 percent tax on some highway tolls and state-owned enterprises to fund the construction of cow shelters and pledged money to each district to deal with stray cattle.

But the problem is enormous. Bandhu, the local administrator for part of Hathras district, at first moved cows from the protesting villages to government-run shelters. When they filled up, officials quickly opened two temporary shelters nearby. Now they too are full, holding 2,800 cattle.

The current plan is to use public land and government funds to construct a cow shelter in every village, said Bandhu, an energetic young bureaucrat whose official title is sub-divisional magistrate. “We are working on a war front,” she said.

Still, as the sun slipped below the horizon on a recent evening, farmers once again lit fires of dried grass near their fields and began their vigils. With a scarf wrapped around his head, Praveen Chaudhary, 22, and his cousin Jeevan Singh, 21, settled in for a long, cold night outdoors.

Suddenly there was a flash of movement at the far edge of the expanse: at least six stray cows. As the two cousins ran down to investigate, three more cows emerged from a stand of shoulder-high mustard plants. Chaudhary and Singh drove the animals toward a road, where another farmer ran after them with a stick.

This was all Yogi’s fault, the two young men said, referring to the leader of Uttar Pradesh by his first name. In the past, chasing after cows “wasn’t a regular, daily thing,” said Singh. “Now they terrorize us.”