Sukarno, a retired truck driver, used to live in a riverside slum plagued by crime and disease in Solo, a small city in central Java. Apart from the coming and going of fetid flood waters, nothing much had changed there for decades until a little-known furniture maker called Joko Widodo became the city’s first directly elected mayor in 2005.

He made it his mission to turn round the flagging prospects of his home town of 500,000, which was blighted by poverty, chaotic streets and an inefficient bureaucracy.

When the mayor, known in Indonesia as Jokowi, first turned up on the muddy pathways of Kampung Sewu, the illegal settlement that was home to Sukarno, 66, the residents resisted his proposals to relocate them to a purpose-built village. But Mr Widodo kept returning until he had convinced about 100 families to move with an offer of free land and funding to build their own homes.

“Life is much better here,” says Sukarno, as he shows off his new house in the neat, simple development to which the community moved en masse. “We like Jokowi because he cares about the ordinary people and dealt with us directly. He didn’t just send his staff.”

Three years after Sukarno moved out of the slum, Mr Widodo has been propelled from the obscurity of provincial politics to the global spotlight: he is the frontrunner to become the next president of Indonesia , the world’s third-biggest democracy. If he wins on July 9, it will cap a meteoric political rise – an Indonesian equivalent of President Barack Obama’s journey to the White House.

In a country where frustration with the self-serving, graft-prone elite is widespread, Mr Widodo’s folksy charm, corruption-free reputation and record of delivering basic services helped him beat the powerful incumbent to win election as the governor of Jakarta in 2012. No sooner had he taken office in the capital than he was topping polls to become Indonesia’s next president, with Susilo Bambang Yudhoyono, the incumbent, stepping down after reaching the two-term limit, amid growing dissatisfaction with his leadership.

But since being confirmed as the presidential candidate for the opposition Indonesian Democratic party-Struggle (PDI-P) in March, the 53-year-old Mr Widodo has struggled to live up to incredibly high expectations. In televised debates and on the campaign trail, his poor rhetorical skills and lack of high-level political nous have been exposed ruthlessly by Prabowo Subianto, his rival for the presidency, former special forces general and self-styled strongman.

Mr Widodo’s poll lead over Mr Subianto, which was as high as 30 percentage points before legislative elections in April, has fallen to just 4 points, according to the Indonesian Survey Institute, a local pollster. It put Mr Widodo on 43 per cent and Mr Subianto on 39 per cent, with 18 per cent undecided. Some in Mr Widodo’s team concede that the gap may be even closer than that.

The significant number of foreign investors and Indonesians who were captivated by Mr Widodo’s reformist credentials are starting to ask whether he really has what it takes to become the first non-elite president of Indonesia’s democratic era.

It is a crucial question as the economy faces a host of immediate and medium-term economic and political challenges. Whoever wins the presidency and takes office in October will have to tackle a widening budget deficit, a ballooning fuel subsidy bill and difficult negotiations over a new minimum wage.

At the same time, economic growth has fallen to its lowest level in five years as a cooling Chinese economy has hit demand for exports such as coal, palm oil and rubber.

During the next five years, the new president will have to tackle seemingly intractable structural problems: endemic corruption, inadequate infrastructure, rising social inequality, a lack of legal certainty and failing health and education systems. He will also bear responsibility for consolidating a vibrant young democracy.

If the next president fails, there is a real risk that Indonesia’s demographic dividend – about half the population of 250m is under 30 – will turn into a demographic time-bomb.

“Much of Indonesia’s recent progress has been due to good luck, not good policy,” says Rodrigo Chaves, the World Bank’s country director. “Many Indonesians are yet to benefit.”

Raden Pardede, vice-chairman of the president’s economic advisory committee, says that while Mr Widodo and Mr Subianto have both promised to improve the country’s infrastructure and the agriculture and education systems, neither has shown properly how these plans will be financed and implemented. “In Indonesia, success is not about the programme but the character of the leader,” he says.

Born in Solo in 1961, Mr Widodo studied forestry at Gadjah Mada university, one of Indonesia’s best, in the nearby city of Yogyakarta.

He followed his family into the local lumber industry, setting up a furniture factory and exporting products around the world. He became head of the Solo furniture makers’ association in 2002. He passed control of the business to his brother-in-law three years later, when he became mayor, but it has continued to grow at a steady pace.

Mr Widodo says that his experience as a furniture exporter shaped his pragmatic approach to politics and his focus on tackling problems rather than theorising. He also cites his private sector background to reassure Indonesian and international investors of his commitment to market competition, despite his regular comments in support of popular protectionist policies.

“For 24 years, I exported furniture,” he told hundreds of people at a recent business meeting in Jakarta to promote his economic agenda. “I may have the face of someone who comes from the village but I have an international brain.”

While some of Indonesia’s influential tycoons were present at the event and others are backing Mr Subianto, most are keeping quiet so that they can preserve their business interests whoever wins.

Mr Widodo combines a studiously honed down-to-earth style and a record of delivering better services. Even his rivals concede that one reason voters like him is because he looks and sounds like an ordinary person, rather than a member of the flashy elite that dominate business and politics in Indonesia. The wealthy Mr Subianto flies around in helicopters and private aircraft, and lives in an expansive hilltop ranch outside Jakarta, where he keeps thoroughbred horses, dogs and a falcon. Mr Widodo, by contrast, wears cheap shirts, plain trousers and shoes, and usually travels in a standard family car.

His previous electoral success was driven by notable reforms, such as expanding access to health and education services and cutting red tape for businesses. “There has been a lot of change in Solo, with riverbank slum dwellers moved to new villages, streets vendors relocated to permanent markets and the overall reputation of the city improved,” says John Taylor, an urban planner who worked with Mr Widodo in his home town. “His biggest challenge was getting the bureaucracy to work with him. It took him three years but after that he was able to move faster.”

According to those close to him, his re-election in Solo in 2010, with an unprecedented 90 per cent of the vote, persuaded Mr Widodo that he was destined for greater things.

In the 20 months since he took office in Jakarta, Mr Widodo has faced similar obstacles with local officialdom. But in the sprawling, congested capital – the world’s second-biggest metropolitan area after Tokyo – he has struggled to exercise his simple management style of delegating decisions and using spot checks to expose problems.

His record is a mix of successes and failed initiatives. He has implemented a plan to make basic health and education free for the poor and work has started on a long-delayed metro system. But he has not managed to kick-start a high-profile monorail project, and a drive to revamp the Tanah Abang textile market, southeast Asia’s biggest, upset many traders.

In interviews, public appearances and meetings with diplomats, Mr Widodo plays down his ambition, insisting he has simply been in the right place at the right time. But those who have worked with him say that, in private, he shows political cunning and calculation.

In depth Indonesia elections The world’s third biggest democracy is holding parliamentary and local assembly elections in April, followed by a presidential poll in July

After the PDI-P fared worse than expected in April’s elections, despite coming first with 19 per cent of the seats in the House of Representatives, Mr Widodo fretted over how to adjust his personal image on the campaign trail. He took quiet soundings on whether he should wear his trademark red-and-blue checked shirt rather than the party colours. He opted for the former but, throughout the campaign, has remained nervous about upsetting powerful figures in the party, not least Megawati Sukarnoputri, the party chairman and former president, and her family.

Despite his popularity, one of Mr Widodo’s political shortcomings has been his reliance on the backing of Ms Sukarnoputri and his inability to win the full support of those in the PDI-P who worry that his sudden rise represents a threat to their positions.

Marcus Mietzner, a lecturer in Indonesian politics at Australian National University, who has tracked Mr Widodo’s rise, says that divisions in the PDI-P have hampered the legislative and presidential election campaigns, allowing Mr Subianto to win back the support of many voters.

But the campaign has also revealed Mr Widodo’s personal limitations, giving fuel to critics in Mr Subianto’s camp who contend he is not ready for the presidency. “Mr Widodo prefers practical problem-solving to engagement with abstract, intellectual discussions,” says Mr Mietzner.

In Solo and Jakarta, Mr Widodo has relied heavily on strong-willed deputies to implement his plans. When the Financial Times spent a day with him in November as he conducted his habitual checks on city officials and projects, he took only one phone call. When asked why, he said that Basuki Tjahaja Purnama, the deputy governor, was handling the nitty gritty issues as usual.

If delegating is his way of governing, it is his ability to channel popular aspirations that could get him elected.

An Indonesian investor who has worked closely with Mr Widodo says that, in this respect, he shares an important political attribute with Mr Obama. “Obama wrote that he serves as a blank screen on which people of vastly different political stripes project their own views,” he says. “Mr Widodo is the same. He doesn’t give much away but people can invest in him whatever hopes they want, whether it’s a poor mother hoping he will increase spending on her local health clinic or an investor who hopes he will improve the business climate. If he wins, we will only start to see what he is really like when he selects his cabinet.”

For one-time slum dwellers such as Sukarno or Udin, a former street hawker whose sales jumped by 50 per cent after he was relocated by Mr Widodo to the purpose-build market in Solo, their hopes are clear.

“Jokowi is a good leader. He is brave enough to listen directly to the complaints of the market traders,” says Udin. “From his record as mayor of Solo and governor of Jakarta, I’m sure Jokowi will be a great president.”

But if he is to win the presidency, Mr Widodo will have to convince the vast majority of Indonesia’s 186m voters who have never experienced his leadership style that he can apply an approach honed as a small-town mayor to the world’s biggest archipelago nation.

A former general who will not cave in easily

The man who stands between Joko Widodo and the presidency is Prabowo Subianto, below, a former special forces general.

Few elections present voters with such a stark choice: a softly spoken, small-town businessman turned mayor on one hand and a bombastic military man who sits at the heart of Indonesia’s narrow political and business elite on the other. Yet their head-to-head race has become increasingly bitter.

Ironically, it was Mr Subianto’s Gerindra party that helped Mr Widodo win the governorship of Jakarta as an underdog in 2012. But, after that victory, the former general’s poll ratings were overtaken by the political outsider he had backed.

Having eyed the presidency for more than a decade, this one-time protégé and former son-in-law of Suharto, the long-ruling dictator, was not about to cave in easily. The 62-year-old, whose military background, international education and aristocratic heritage contrasts sharply with Mr Widodo’s humble beginnings, has batted away persistent allegations about past human rights abuses and a fiery temper.

When speaking in fluent English to international audiences, he emphasises his desire to tackle corruption, build much-needed infrastructure and ensure legal certainty for investors. But Mr Subianto’s domestic pitch is focused on his military exploits, his muscular leadership style and emotion-laden claims that he is the only one who can stop “foreign lackeys” from pillaging the country.

As Mr Widodo’s campaign has struggled, Mr Subianto has bounced back strongly in the polls, supported by a broad coalition of establishment figures and the wealth of Hashim Djojohadikusumo, his tycoon brother.

Fadli Zon, vice-chairman of Gerindra, argues that while Mr Widodo has a decent record in local government, it is no preparation to lead a vast nation with many different ethnic and religious groups.

It is a view shared by many Subianto supporters including Martin Nupapaty, a retired merchant seaman from Papua. “People want honest and firm leadership and they see that in Mr Subianto,” he says.