Narendra Modi’s ruling Bharatiya Janata party has lost its parliamentary majority, dealing an unexpected blow to the prime minister and forcing him to negotiate with coalition partners in order to return to power.

With all votes counted early on Wednesday morning, it was clear that the landslide for the BJP predicted in polls had not materialised and instead there had been a pushback against the strongman prime minister and his Hindu nationalist politics in swathes of the country.

The party lost 62 seats, bringing its total down to 240, below the 272 required for a parliamentary majority.

It is the first time since Modi was elected in 2014 that the BJP has not won a clear majority on its own. Nonetheless, together with its political allies, known as the national democratic alliance (NDA), its win amounts to about 292 seats, which is enough to form a majority government to rule for the next five years and return Modi to office for a third term.

The fake news divide: how Modi’s rule is fracturing India – video

Meanwhile, the opposition alliance, which goes by the acronym INDIA, far outperformed expectations, collectively winning more than 230 seats. The alliance, formed of more than 20 national and regional opposition parties, had come together for the first time in this election with the aim of defeating Modi.

Despite the tight race, Modi insisted he had been given a mandate to lead again in a victory speech. Addressing voters at the BJP headquarters in Delhi, Modi said he was “very, very happy today”.

“I would like to bow down before the people of the country,” said Modi. “Today is an emotional moment for me personally as well. This was my first election after I lost my mother.”

“The blessings of the people for the third time after 10 years boosts our morale, gives new strength. Our opponents, despite being united, could not even win as many seats as BJP won.”

BJP officials were insistent it would form the next government and denied any setback, emphasising that their party had won more seats than any other.

“The NDA will form the government for the third time. Prime Minister Modi will be sworn-in for the third time. Congress will sit in opposition for the third time,” said Jaiveer Shergill, a spokesperson for the BJP. He added that “introspection” would be done within the parties about their losses.

Trinamool Congress party supporters in Kolkata, eastern India. Photograph: Piyal Adhikary/EPA

The INDIA coalition proved more resilient and successful than many analysts had expected, despite grappling with state agencies freezing party funds and jailing opposition leaders in the buildup to the polls. They were particularly boosted by regional parties who far outperformed the BJP, such as the Samajwadi party in Uttar Pradesh, the Trinamool Congress in West Bengal and Dravida Munnetra Kazhagam party in Tamil Nadu.

“We have to credit the opposition alliance for being more politically and electorally savvy than it might have been given credit for,” said Michael Kugelman, director of the Wilson Centre’s South Asia Institute.

“So many had left the opposition for dead and had not expected it to be able to capitalise on a number of BJP vulnerabilities in the last few years, whether that’s economic stress or pushback against Hindu nationalism. But instead, they’ve done pretty well.”

Analysts said the results would have significant implications for India’s political landscape after the polls. Since he was elected a decade ago, Modi and his Hindu nationalist BJP have enjoyed a powerful mandate, while the opposition have been seen as weak and unable to stand up to the might of the party. Modi is seen as a popular strongman prime minister and stands accused of overseeing increased authoritarianism and a crackdown on dissent over his decade in office.

Maya Tudor, associate professor at Oxford University’s Blavatnik school of government, said: “Particularly in the Hindi heartland, which is the BJP’s core base, voters have not delivered the expected Modi wave. So relative to expectations, you can read this as a loss for the BJP.”

The results were a particular triumph for the country’s beleaguered main opposition party and the BJP’s main rival, Indian National Congress, which dramatically lost the previous two elections to Modi and was facing questions about its future as a party. This time it appeared the Congress party had more than doubled its seats.

skip past newsletter promotion

Graphic seats won by parties

Mallikarjun Kharge, president of the Congress party, said Modi had faced a “moral and political defeat” and said the opposition coalition would meet on Wednesday to discuss their next steps. “We focused our fight on the unemployed, the farmers and the poor of this country. The BJP, meanwhile, spread lies and hatred, running a vicious campaign. People have rejected that,” said Kharge.

Mamata Banerjee, head of the opposition Trinamool Congress party that swept the seats in West Bengal, called on Modi to step down. “These results have shown that Modi has lost all credibility and he should immediately resign,” she said.

The BJP centred its campaign around the cult of the prime minister, their party manifesto simply titled “Modi’s guarantee”. Many of his speeches initially focused on the BJP’s mammoth infrastructure push, generous welfare programmes and elevation of India on the world stage over the past decade, as well as promises to turn the nation into a $10tn economy.

However, in what some took as a sign of nervousness in the BJP camp, Modi later turned to more polarising religious rhetoric on the campaign trail, appearing to call Muslims “infiltrators” and “those who have more children” while in a flurry of interviews he proclaimed to have been chosen by God for the role. The BJP was also accused of harassing and intimidating political opponents to prevent them running and of suppressing Muslim votes.

Analysts said results indicated that the “Modi wave” had been dented by problems such as high unemployment and inflation. In the aftermath of the election, Modi will probably have to grapple with a more powerful and more animated opposition than at any point over the past decade.

The BJP’s ability to continue with its more hardline Hindu nationalist policies could also be impeded as it is forced to rely on its coalition partners, some of which do not have the same Hindu-first agenda, and analysts said Modi could be forced to take a more pragmatic or consensus-based pathway in policy than ever before.

A BJP supporter carries a cutout of its logo with pictures of its leaders Narendra Modi, Amit Shah and Jagat Prakash Nadda. Photograph: Niharika Kulkarni/AFP/Getty Images

One of the biggest shocks of the election results was the vast losses faced by the BJP in the Hindi heartland of Uttar Pradesh, the country’s most populous and politically important state, which has 80 seats and is seen as a bellwether for the rest of the country. Early counts showed that the INDIA alliance was ahead of the BJP’s alliance, with several BJP heavyweights losing their seats, indicating that the party had lost critical support in one of its key bastions.

The results also threw up other surprise outcomes. In one significant success for the BJP, they managed to win their first seat in Kerala, long seen as a bastion of leftwing politics, which had pushed back hard against Hindu nationalist politics. Meanwhile, in Modi’s own constituency of Varanasi, his victory margin shrank from half a million votes to 150,000.