Helmand's dusty towns, poppy fields and insurgent hideouts are a difficult place for government officials, so dangerous and marginal that during Afghanistan's last presidential election five years ago, not a single candidate bothered to visit.

So when Ashraf Ghani Ahmadzai chose Lashkar Gah's fading stadium to launch his series of nationwide rallies this spring, it was an bold statement of ambition and intent in his search for votes from every corner of his diverse country. "I am coming to the most troubled province to demonstrate that Helmand has a different face. This is about the rebranding of Afghanistan," he said, after addressing a crowd of more than 2,000 people, surrounded by local politicians and tribal leaders.

But the rally was also a triumphant celebration of the former World Bank technocrat's unlikely journey from embarrassed also-ran in the 2009 election to one of three serious contenders to lead the country when President Hamid Karzai steps down this year.

Ghani's transformation has electrified an election campaign that many had expected to be a two-way race between a Karzai-backed candidate and the president's main rival from 2009, Abdullah Abdullah. Instead it is now a fierce, and wide open, competition.

"He has learned to be a politician," one campaign aide admitted, as Ghani met Helmand powerbrokers behind closed doors to barter for support.

Although he is from the Pashtun ethnic group that dominates south Afghanistan, Ghani's tribe has traditionally had more clout in the east. But in Lashkar Gah he attracted local leaders whose loyalties might once have been with rival Pashtun campaigns, including Haji Abdullah Khan, from nearby Kandahar.

The 37-year-old said he had backed Karzai in the past two elections, like most of his Achakzai tribe, but was considering switching allegiances and had driven over that morning to meet Ghani. "President Karzai didn't pass his test, development programmes never happened, there is no electricity. Even if he was running again we wouldn't vote for him," he said. "In [Ghani's] character we see peace and the development of Afghanistan."

When Ghani announced his first run in 2009, it was as a modernising moderate whom many westerners saw as a perfect candidate. A university chancellor and ex-finance minister, he was a public intellectual nominated for secretary general of the UN, untainted by corruption rumours that swirl round many powerful Afghans.

Bill Clinton's master strategist James Carville signed up to run his campaign for free, complete with theme tune that could be downloaded as a mobile ring-tone. But his team forgot to check his appeal to the voters. Most Afghans are still illiterate farmers, with a tradition of voting in ethnic blocks, and where civil-war-era warlords are as loved by their followers as they are hated by the people who suffered at their hands.

He won barely 3% of the ballots cast, and many assumed it was the end of his political career. Instead, it became a lesson in electioneering at home, after two decades living overseas and even taking US citizenship, though he renounced his American passport in 2009.

In 2011 he got a position as co-ordinator of the security handover from Nato to Afghan forces, which demanded travel to every province, talks with local military and political leaders, and the redistribution of shrinking resources. He denies campaigning on the job, but his trips involved rousing speeches to parade grounds packed with soldiers, and in-depth discussions about each area's challenges and strengths that made him seem very much like an aspiring politician. He started adding his tribal name, Ahmadzai, to "Ashraf Ghani", emphasising his roots in a province south of Kabul, and mostly ditched western suits for traditional loose trousers and shirt.

Still his campaign plans were widely dismissed in Kabul as a second quixotic bid for an office beyond his reach, until he revealed his main running mate would be Abdul Rashid Dostum. An Uzbek warlord who made his name during the civil war and then fighting the Taliban, he is a controversial but powerful figure who commands a large block of votes.

In a 2009 letter to the Times, after Dostum backed Karzai's campaign that year, Ghani denounced the commander as a "known killer". But now he has decided the support Dostum can muster among Uzbeks and Turkmen voters in the north, where he is revered by hundreds of thousands, is more important than his past. "Had General Dostum gone to another ticket, my winning would have become theoretical," Ghani said in the conservatory of his understated home in west Kabul, shortly before the Helmand gathering.

He has wrung a near apology for past crimes out of Dostum, who said in a message on Facebook: "We apologise to all who have suffered on both sides of the wars." Although low-key and somewhat reluctant, it is the closest any civil war commander has come to saying sorry, and Ghani presents it as proof of Dostum's commitment to his reformist plans. "It's a ticket that is going to win in order to bring out an agenda of transformation. Without putting together an electoral ticket that can win, all these ideas remain just that," he added.

The alliance shocked Kabul's political elite and cost Ghani voters among the educated urban professionals attracted by his clean past and pragmatic programme, but the losses seem to have been more than balanced – as Ghani anticipated – by the gains from Dostum supporters.

Afghanistan has had few opinion polls, but most published so far put him in the runoff or within reach of it. He insists, though, that political compromises he has made will not change how he rules, sticking to the campaign promise of "change and continuity". "Power is not an end, I have no need for power," he said. "But if I am going to fulfil my desire as an Afghan citizen, then I need to be able to shape policy directly, and that requires winning, and this is a winning ticket."