Sensing his party's drive for votes in India's most politically prized state had stalled, Prime Minister Narendra Modi cleared his schedule and thrust himself into the heart of the battle.
"Our election campaign has hit a roadblock," Modi told campaign managers and two federal ministers in Delhi last month, a week before the sixth of seven phases of voting was to begin in Uttar Pradesh.
"I don't want to feel that I could have pushed myself a little more," Modi was quoted as saying by a close aide who attended the meeting.
For three full days the leader of the world's largest democracy camped out in the holy city of Varanasi, his parliamentary constituency, walking the ancient streets and stopping at Hindu temples to seek blessings, despite warnings from aides about his security and the risk to his reputation had his party come up short.
On Saturday the gamble paid off: Modi's Bharatiya Janata Party (BJP) scored a thumping victory in Uttar Pradesh, home to one in six Indians, winning the biggest majority in the state for any party since 1977.
The triumph vindicates Modi's decision to turn the campaign into a referendum on his own performance after his shock decision last November to abolish high-denomination banknotes, a move he framed as a fight for the poor against the corrupt rich.
"We were always nervous that overexposing the prime minister in the final stages of the election could make us look desperate," said Keshav Prasad Maurya, the BJP's state leader in Uttar Pradesh.
As it turned out, Modi's victory confounded even the most bullish voter surveys. The BJP won 312 of the 403 seats in the state assembly and, with 39.7 per cent of the vote, almost matched its showing in Uttar Pradesh in the 2014 general election, when it claimed the biggest parliamentary majority in three decades.
"Modi's magic has destroyed the opposition and silenced sceptics in the party," Maurya told Reuters on Saturday, as the scale of the victory became clear.
The win clears a path to victory for Modi at a 2019 general election, and gives him a free hand to consolidate his grip over a state that sends the highest number of federal lawmakers to parliament.
That has raised hopes among investors that the BJP will embark on a round of new reforms to boost growth in Asia's third-largest economy, and try to tackle the corruption and red tape that has long undermined India's potential.
Economists now expect Modi to launch initiatives aimed at flushing out ill-gotten gains from real estate, gold and campaign finance.
But they caution that his biggest task remains transforming India's economy into one that creates enough jobs for an emerging generation that is desperate to give up life on the farm for a more prosperous future.
"Jobs is the biggest risk," said Rajiv Kumar, an economist at the Delhi-based Centre for Policy Research. "That's where he has to focus very hard and it could mean reforms as radical as demonetisation."
Modi's BJP now heads the government in states where more than half of Indians live, while the Congress party, which has ruled India for most of the 70 years since independence, leads in regions covering less than 8 percent of the population.
Success will increase the pressure on Modi to provide for an increasingly aspirational nation of 1.3 billion people, half of whom are aged 25 or under.
"He has to do a very delicate tightrope walk between being reformist and populist," said Nilanjan Mukhopadhyay, a journalist and biographer of Modi. "The problem in India is that people think reforms are pro-rich."
Modi relied on his own charisma to clinch crucial votes in poor and agrarian Uttar Pradesh, but his campaign manager Amit Shah also takes credit for fielding the right candidates in a region where many people vote along caste and religious lines.
Critics accuse Shah and Modi of "social engineering" and of switching to a more communally divisive tone to fire up their Hindu base as voting, staggered over the course of a month, progressed.
Shah vowed to construct a Hindu temple on a razed mosque site and ban the slaughter of cows, worshipped by millions of Hindus.
On the campaign trail, too, Modi played up religious divisions by asking why the state government ensured there were no power cuts in the Muslim holy month of Ramadan but not during the Hindu festival of Diwali.
Still, the BJP likely collected minority votes, including Muslim women whom he courted by questioning an Islamic practice that allows men to divorce their wives with three simple words.
"The results prove that Muslims and backward caste groups voted for the BJP," said RK Mishra, a political analyst in Lucknow, the state capital of Uttar Pradesh.