AYODHYA, India (Reuters) -The opening of a grand Hindu temple just three months ahead of India's general election was supposed to be a crowning moment for populist prime minister Narendra Modi that would carry his party to a dominant victory with its Hindu-first agenda.

It didn't work out that way.

Instead, Modi's Hindu nationalist Bharatiya Janata Party (BJP) lost the seat in Ayodhya, where the temple is located. In the surrounding state of Uttar Pradesh, a traditional stronghold for the party and one that sends the most lawmakers to parliament, its tally of seats was nearly halved.

    Although the BJP and its allies can form a coalition government to keep Modi in power as prime minister for his third term, the margin of the victory was much smaller than pollsters had predicted and sent a shockwave through Indian politics.

    The message from voters in Ayodhya and across swathes of Uttar Pradesh is that the BJP's pro-Hindu agenda was not enough. Other campaign tacks of record economic growth and free-food programmes were overshadowed by unemployment, the cost of living and the widening gap between the urban and rural economies.

"Everyone loves Lord Ram, but without work and income, what can one do?" said Nankan Yadav, a 55-year old Hindu farmer, one of 18 people interviewed in the town by Reuters. Yadav said he switched to the opposition Samajwadi Party after voting for the BJP in the last two elections.

He said he was the sole earner in a family of five, with his three children either studying or jobless.

"Inflation and unemployment are the issues on which people have voted. We have voted to bring the focus back on unemployment," he said, as earth-movers dredged his front yard to widen a public road, a common feature across the city as it grows to accommodate more visitors.

Twenty-four-year-old Mohammad Shahid, whose income driving an electric rickshaw supports his parents, wife and two young children, said he too voted for the Samajwadi Party because he was struggling with high electricity bills, monthly instalments for the loan on his vehicle and other costs.

"Rates for everything keep rising," he said.

The ruling BJP lost a third of its rural parliamentary seats, with analysts saying this was down to discontent over a lack of jobs and inflation in the countryside.

FRINGES TO DOMINANCE

Over the past half-century, the BJP has risen from the fringes of mainstream politics to become the country's most dominant party on the back of its ideology of muscular Hinduism, underlined by the campaign to build the Ram temple on the site of a 16th-century mosque.

Its landslide victories since 2014 in a series of general and state elections, India's stellar economic growth and Modi's huge personal popularity may have led to over-confidence, analysts said.

"In a state like Uttar Pradesh, the temple is not the only deciding factor any more (unlike) development issues...and unemployment," said Surendra Kumar Dwivedi, a former head of the political science department at Lucknow University.

Unemployment and inflation were the two biggest reasons nationally for people to go against Modi's alliance, according to a survey of 20,000 voters by the CSDS-Lokniti polling agency for the Hindu newspaper. Some 30% of the voters were worried about inflation, a jump from the 20% prior to the election, while unemployment was a factor for 27%.

The unemployment rate in India rose to 8.1% in April from 7.4% in March, according to the private think-tank Centre for Monitoring Indian Economy, compared with around 6% before the COVID-19 pandemic.

Modi first came to power in 2014 on the promise of creating 20 million jobs a year, but has fallen far short of that.

While headline inflation hovering around 5% is relatively low, food inflation of above 8% since November 2023 has hit the poor hard. Prices of vegetables and cereals have risen by double digits for most of the last year.

"You are not going to vote because you are swayed by the temple's inauguration," said Ghanshyam Tiwari, spokesperson for the Samajwadi Party that unseated the BJP as the dominant party in Uttar Pradesh.

"You are going to vote because you are uncomfortable about your job situation, you are uncomfortable about the fact that there aren't basic amenities in your house, you are uncomfortable that the government is not doing enough."

WINS ELSEWHERE

To be sure, the BJP swept the neighbouring state of Madhya Pradesh, which analysts say was partly because the opposition alliance did not have a strong local player like Samajwadi in Uttar Pradesh to capitalise on any discontent there.

But the BJP also won all seven seats in the capital Delhi and did well in other states bordering Uttar Pradesh.

Overall, the BJP won 240 seats in India's 543-member lower house of parliament, while its National Democratic Alliance (NDA) won 293, clearly above the 272 majority.

"The 2024 election could be just a pause for the BJP, not a setback," wrote BJP parliamentarian Rakesh Sinha in the Indian Express newspaper.

"The 2024 mandate is for Modi to govern the country for a third consecutive term. He remains the undisputed and most acceptable leader both in his party and the NDA."

In Ayodhya, where large cut-outs of Lord Ram dot the roads and hundreds of people were swarming into the temple despite the scorching summer heat, residents saw things differently.

"They spent crores (millions) of rupees for the temple's inauguration," said Awadhesh Prasad, the Samajwadi candidate who won the Faizabad parliamentary seat where Ayodhya is located. "There is so much poverty in our country, this kind of showing off is not for a democracy like ours."

Long-time BJP voter Krishna Shankar Pandey, a 65-year old Hindu priest, said about the party that "whatever votes they got, they got in Ram's name".

"Otherwise they would not have got any," he said, sitting on the street outside his home, shirt-less and clad in a white linen sarong.

(Reporting by Shivangi Acharya; Additional reporting by Saurabh Sharma and Krishna N. Das in New Delhi; Writing by Krishna N. Das; Editing by Raju Gopalakrishnan and Toby Chopra)

By Shivangi Acharya and Saurabh Sharma