India’s only dedicated “cow minister” has been dumped in state elections, ending a controversial tenure during which hundreds of the sacred animals starved to death or were poisoned in state-run shelters.

Otaram Dewasi, the first head of Rajasthan’s cow ministry, was turfed out on Tuesday when the Hindu nationalist Bharatiya Janata party (BJP) was thumped in the western desert state and two other key regional polls.

He was not the only noteworthy casualty from India’s ruling party, with the country’s only “happiness minister” – who stands accused of murder – also tossed aside by voters in central Madhya Pradesh state.

Dewasi, the cow minister who in office wore the red turban and white sarong of a desert herdsman, lost by 10,000 votes to an independent candidate.

Hindus consider cows sacred and the BJP, led by the prime minister, Narendra Modi, has campaigned for their protection at state and national levels, and introduced harsh penalties for mistreating them.

But the cause has spawned cow vigilantism in parts of India, with people accused of carrying beef or slaughtering the animals – especially Muslims and low-caste Hindus, who consume beef – murdered by mobs.

Some of the most high-profile cow-related lynchings in recent times have occurred in Rajasthan, including the brazen beating to death of a Muslim dairy farmer on a busy highway last year.

The state created India’s first ministry exclusively for cow protection in 2015 when the BJP won elections and appointed Dewasi, a police officer turned politician, to be in charge.

He imposed a 20% surcharge on new property purchases – dubbed a “cow tax” – to generate cash to run the 2,300 shelters in his state for abandoned cows. He also branded hundreds of thousands of cows under his care to stop them being smuggled.

But his reputation was marred in 2016 when 500 cows starved to death at a state-run shelter when the facility was flooded during heavy rains.

In August, 28 more died from poisoning, further denting his image in a state where cow slaughter is punishable by 10 years in prison.

The BJP campaigned in the Rajasthan elections on tougher laws for cow slaughter and more money for shelters – but was defeated by the Congress party led by Rahul Gandhi.

Voters in Madhya Pradesh, where Congress also defeated the BJP, booted out Lal Singh Arya, the state minister in charge of India’s only “happiness ministry”, after a scandal-ridden term.

The ministry he helped set up in 2017 was modelled on the “gross national happiness” index used in Bhutan, a tiny Himalayan country, to measure the wellbeing of its citizens.

But weeks after it was inaugurated, Arya was on the run, accused of murdering a political rival in 2009. He was eventually arrested, and his trial is ongoing.

He lost by 25,000 votes to a rival from Congress, which seized Madhya Pradesh after 15 years of BJP rule.

The electoral defeats are seen as a major blow to Modi’s image of invincibility. The BJP had won more than a dozen state elections since Modi soared to power with a thumping majority in 2014.

He is seeking a second term as prime minister when the country goes to the polls by May 2019.