Indian Prime Minister Narendra Modi is poised to keep power for a third term even after voters dealt the Hindu nationalist a stunning setback by denying him an outright majority following an election dominated by high unemployment and inflation. undefined undefined Modi and his ruling Bharatiya Janata Party will now have to rely on allies in his coalition to cross the 272-seat threshold for a majority in the lower house of parliament to form a government. It is the first election since 2014, when Modi won his first term as prime minister, that the BJP hasn’t scored an absolute majority on its own. undefined undefined Modi would be only the second leader after Jawaharlal Nehru , the country’s first prime minister, to return to power for a third straight term. Official results show the BJP winning around 240 seats. It won 303 seats in 2019. undefined undefined Modi, speaking in the evening local time, didn’t acknowledge the upset and claimed a historic victory. “In our third term, the country will write a new chapter of big decisions,” he said. “This is Modi’s guarantee.”

The opposition hasn’t conceded defeat. The Congress party, which ruled India for decades but had seen its popularity plunge in recent years, was set to nearly double its seat count compared with the last general election. Its opposition alliance gained well over 200 seats, far surpassing the performance of the opposition bloc it led five years ago.

In a press conference, Rahul Gandhi , the face of the opposition Indian National Congress party, said the opposition alliance would meet on Wednesday to discuss their options. He said the result was a victory for democracy.

“The deprived and poor population of the country stood with India to protect their rights,” Gandhi wrote on the social-media platform X.

Political analysts said the election results punctured Modi’s aura of invincibility. The 73-year-old leader has long relied on his personal charisma to woo voters, and he campaigned extensively up and down the country in the months leading up to the election season.

“The results show that Brand Modi has diluted,” said Rasheed Kidwai, a political analyst affiliated with the Observer Research Foundation, a New Delhi think tank. “It’s a big setback.”

India’s stock markets plunged on Tuesday, after closing at record highs on Monday due to exit polls that predicted a landslide win for Modi, who had pledged to make India the world’s third-largest economy in his third term. Modi has sought to boost manufacturing in India, and convinced Apple suppliers to invest in the country. These efforts aren’t creating enough jobs for India’s young people.

There were early hints that the BJP was worried about low voter turnout amid a record-setting heat wave searing much of India. Modi began his campaign touting his economic record, but quickly pivoted to attacking Muslims and painting the opposition Congress party as pro-Muslim. In an April speech, he called Muslims “infiltrators” and “those who have too many children.”

During Modi’s time in power, he has foregrounded the country’s Hindu identity. India’s Muslims, the country’s largest religious minority, say they have been politically marginalized and at times targeted with violence as Hindu nationalist ideas became more prominent.

But attempts to fire up his Hindu nationalist base flopped in Uttar Pradesh, India’s most populous state and a political bellwether, where the opposition combined to come out ahead of the BJP, which saw its seat count plunge to the low 30s, down from 62 in 2019.

Modi’s party lost even in the constituency that includes Ayodhya, the site of a controversial Hindu temple inaugurated by the prime minister in January that fulfilled one of his key election promises. That was expected to help him clinch another majority.

Political analysts said that many people appear to have cast their ballots over unhappiness with economic issues. Some voters have questioned the disconnect between two images of India: one of a global economic powerhouse populated by glitzy billionaire moguls, and the second where hundreds of millions of people face bleak job prospects and soaring costs, leaving them reliant on the government’s free food grains program.

Mohammad Ahmed, a 42-year-old laborer from Uttar Pradesh, said he stands at the main traffic intersection in his village, along with hundreds of others, hoping to pick up daily work as a farm laborer. Over the last six years, he said, the number of people waiting at that traffic signal has increased 10-fold.

“Modi distributed free food, but gave no jobs,” said Ahmed. “In the 10 years of Modi’s rule, the rich have become more powerful and the poor more helpless.”

This time, Ahmed switched his vote to Congress. “I used to think of Modi as my father. But he let us down,” Ahmed said.

On Tuesday Ahmed had traveled to the Congress party’s headquarters in Delhi to await the results—and later was greeted with a hug by the face of the party, Gandhi. At the party offices, workers were in a jubilant mood and many chanted, “Long live the people of India.”

The results in Uttar Pradesh were particularly telling because the state has been the home of the Hindu nationalist experiment, said Yamini Aiyar, a public policy expert.

“The everyday lives of the people, the issues around unemployment, the issues around inflation, they mattered,” said Aiyar, adding that Modi may have unintentionally intensified this issue with his campaigning around a pledge to turn India into a developed economy by 2047.

As for the religious messaging, she said, people are “exhausted with Hindu nationalism as the only offering on the table.”

In the neighboring state of Madhya Pradesh, Devi Singh Malviya, a 34-year-old farmer, said Modi’s party was too keen on trumpeting India’s success on the world stage instead of fixing bread-and-butter issues that concern ordinary people. Malviya said he switched his vote to the opposition after backing the BJP in previous national elections.

“The BJP government isn’t focusing on the present problems,” said Malviya, who believes many in his village voted on similar lines. “Instead they have set goals for 2047. What has increased in the last 10 years is unemployment and prices.”

In Delhi, Khemchand Sharma, a BJP party spokesperson, noted that the party had won the largest share of seats, but would analyze the results.

“We will own up what we got right and we got wrong. That’s in our party’s culture,” he said. He said the party may be facing anti-incumbency against local candidates, rather than a rejection of the national leadership’s vision for the country.

Political experts said that the Modi government’s use of its levers of power to quash critics may have cut the party off from understanding the deep levels of economic anxiety that millions of Indians are facing.

Media outlets and civil society organizations have faced tax inquiries and investigations. The Congress party saw increased tax recovery actions ahead of the election, while the head of another opposition party, Arvind Kejriwal , was arrested on corruption charges. The government maintains investigative agencies are following due process in pursuing corruption.

When a government “silences dissent, it doesn’t actually hear what the average person is thinking except in the moment of elections,” said Maya Tudor, associate professor of politics at Blavatnik School of Government at Oxford University, who focuses on India.

Political experts credited the opposition gains in large part to grassroots campaigning by Gandhi, who in recent years has gone on monthslong cross-country walking tours to connect with the public. In speeches across India, he has called for more job creation and less social division.

He had also warned that Modi’s party could dramatically change the constitution if it won a two-thirds majority, a number it initially claimed it would reach, including taking away affirmative-action programs that guarantee slots in government and in universities for minority groups.

In Uttar Pradesh, a large population of India’s traditionally oppressed caste groups, the Dalits, appear to have swung strongly to the opposition this time, for both economic reasons and over concerns about Modi’s Hindu platform.

Gurmeet Singh, 18, a first-time voter from the Dalit group, said that ahead of the vote counting, he and his neighbors went to a local Hindu temple to pray for an opposition victory.

“This election is about saving our constitution and the rights it gives us,” said Singh. “Modi and BJP are actually anti-Hindu for using Hinduism for their political gains. They are also anti-India for dividing people on the basis of religion.”

Write to Krishna Pokharel at krishna.pokharel@wsj.com and Vibhuti Agarwal at vibhuti.agarwal@wsj.com