India’s prime minister, Narendra Modi, has claimed a landslide victory in national elections that cements the Hindu nationalist leader as the country’s most formidable politician in decades.

Modi’s ruling Bharatiya Janata party (BJP) had been expected to easily form a governing coalition with smaller allies, but official results showed the party ahead in at least 300 seats, comfortably beyond the 272 seats required for a majority in the lower house of parliament.

Its main national opponent, Congress, was leading in just 50 constituencies and its party president, Rahul Gandhi, was turfed out of his family’s bastion seat of Amethi in Uttar Pradesh state.

“Together we grow,” Modi said on Twitter as the results came in. “Together we prosper. Together we will build a strong and inclusive India. India wins yet again!”

In a later televised address, he was critical of those who had doubted the BJP could increase its majority. “The political pundits of India have to leave behind their ideas of the past,” he said.

This year’s polls, held over seven phases starting on 11 April, have been described as a contest for the soul of India. They pitted Modi’s Hindu nationalist government against a disparate group of opposition parties including Congress, whose secular vision has defined the country for most of the past 72 years.

Votes from 542 lower-house constituencies – one fewer than usual after authorities discovered £1.3m in unaccounted cash in a south Indian party leader’s home and cancelled the poll there – started being counted at 8am local time (3.30am GMT), and results were released progressively throughout the day.

Facebook Twitter Pinterest BJP supporters in Bangalore on Thursday. Photograph: Jagadeesh Nv/EPA

By early Thursday evening the BJP had won in close to 20 constituencies in the crucial state of West Bengal – up from just two seats in 2014 – while holding off a co-ordinated challenge from opposition parties in the Hindi heartland states of north India, where its support had been expected to fall from the high watermark of five years ago.

Now it appears 2014 was no aberration, and that Indian politics has likely entered a new era of Hindu nationalist hegemony fuelled by Modi’s extraordinary popularity.

“We are in an era where you have, once more, a central gravitational force around which Indian politics revolves,” said Milan Vaishnav, the director of the south Asia programme at the Carnegie Endowment for International Peace. “I think 2019 will confirm that the BJP has replaced the Congress as that.”

Nationalist agenda

The emphatic victory will be greeted with dismay among some members of religious minority groups, who have voiced fears that a returned BJP government would be further emboldened to prosecute its Hindu nationalist agenda, including controversial citizenship-status checks to root out unauthorised migrants in border states.

The BJP’s president, Amit Shah, described illegal migrants in the country’s north-east as “termites” in one speech that was widely condemned by opponents.

Among the BJP candidates who won on Thursday was Pragya Singh Thakur, a Hindu nun and terrorism accused who is still facing trial for involvement in a 2008 bombing plot that killed six Muslims and injured scores of others.

A lifetime of material: a comedian's guide to the Indian election Read more

Alongside nationalism and Modi’s personal magnetism, the BJP’s victory was also fuelled by a relentless, data-driven and highly disciplined style of campaigning.

The party sent up to 20 campaigners to manage the area around each polling booth, ensuring they knew their possible voters and what messages would resonate with them, an evolution from the older style of courting or inducing local chieftains to bring out their villages to vote.

“We had organisations sitting in every booth and that’s unprecedented,” said Rajat Sethi, a BJP strategist.

Modi the master

The decisions of voters in the vast country of 1.3 billion people have been driven by innumerable local concerns, caste and religion, or rumours and opinions traded over WhatsApp or cups of chai at a tea stand. But the figure of Modi has towered over the contest like no prime minister since Indira Gandhi in the 1970s.

“There is no match for Modi among the opposition parties,” said Rahul Verma, a fellow at the Delhi-based Centre for Policy Research. “He’s running at nearly an all-time high popularity. He’s charismatic, and people still repose faith in him despite not being very happy with the economic side of the government’s performance.”

A survey released this week by the Centre for the Study of Developing Societies found that nearly one-third of people who voted for the BJP did so in support of Modi, rather than the party or their local candidate. Modi’s popularity had actually grown compared with 2014, when he led his party to the first majority victory in 30 years, the researchers said.

The months leading to the election were bumpy for the BJP. A government survey revealed unemployment to be the highest in 45 years. Data showing that farming incomes had plummeted to their lowest point in 18 years confirmed the distress of agricultural workers, some of who had marched on Delhi carrying skulls that they said belonged to farmers who had committed suicide due to drought and mounting debt.

Modi’s promise on the 2014 campaign trail that “good days are coming” threatened to turn into a millstone around his neck.

Is India the frontline in big tech’s assault on democracy? | John Harris Read more

Then a bombing in the disputed territory of Kashmir on 14 February helped to transform the contest. Rather than dent Modi’s strongman image, the killing of 40 Indian paramilitaries by a Pakistan-based militant group became the stage for his response, an airstrike deeper in neighbouring territory than Indian jets had ever struck.

“It really put a premium on leadership,” said Vaishnav. “It spoke to the attributes that Modi often touts about himself: decisiveness, muscularity, nationalism and to a certain extent people started to see the vote not about a choice between political alternatives but a vote for the nation.”

Modi styled himself as “chowkidar” – Hindi for watchman – and made national security the dominant message of the early part of his campaign.

Congress licks wounds

Congress never found its footing again after the Pakistan strikes and has been outgunned by the BJP’s deep pockets and disciplined party machine.

Conceding defeat on Thursday evening, Gandhi declined to speculate on what had gone wrong. “What matters is that the people of India have decided that Narendra Modi will be prime minister, and as an Indian person I respect it,” he said.

Gandhi will continue to serve in parliament from a second seat in Kerala state that he won handily on Thursday.

A report by the Association for Democratic Reforms (ADR) found that the BJP took in more than 73% of the donations declared by India’s seven largest political parties in 2017-18. The ruling party spent more than 260m rupees (£2.9m) on advertisements on Facebook, YouTube, Google and Instagram, compared with 35m rupees by Congress.

Many opposition leaders tried to paper over their differences to form a broad anti-Modi coalition. They said it would be enough to oust the leader, who won office with just over 30% of the national vote share five years ago. But their alliance was purely instrumental and had failed to inspire voters, Verma said.

The process of counting more than 600m votes used to take up to 40 hours but the growing use of electronic voting machines since 1982 has made things considerably quicker.