JAKARTA (Reuters) - When he was nominated in March as a candidate for Indonesia's presidential election, polls showed Joko "Jokowi" Widodo had a 30-point lead over the man who would become his main challenger, former army general Prabowo Subianto.
But after three months of shambolic and lacklustre campaigning, the wildly popular governor of Jakarta was staring at defeat.
"If you continue like this, it's clear we will lose," prominent businessman Sofjan Wanandi told Widodo and senior members of his Indonesian Democratic-Party of Struggle (PDI-P) at a crisis meeting on June 16.
With election day less than three weeks away, Widodo had just been given a poll showing Prabowo trailed by only 1.8 points.
"'No more discussion. We have to start fighting'," Widodo told the stunned gathering at a Jakarta hotel according to Wanandi, a key financier of Widodo's campaign, recalling the drama in a recent interview with Reuters.
That meeting was the turning point. Galvanized by an army of young, social media-savvy volunteers, and by what one advisor called "fear of losing", Widodo's campaign kicked into gear. He eventually beat Prabowo by about six percentage points, with 53.15 percent of the 130 million votes cast on July 9.
Alleging "massive cheating", Prabowo still disputes the result and has so far refused to call Widodo to congratulate him on his win. On Aug. 21, Indonesia's constitutional court unanimously rejected his last-ditch bid to overturn it.
DECADE OF EXPERIENCE
Aides insist Widodo's amateurish campaign does not presage an equally tepid and directionless presidency. A close media advisor said the near-miss will make him a stronger leader.
"This will be a president who takes risks but who has learned a lot about the country through the campaign," he said. "He's like a sponge. He learns from people and from his experiences."
Lukewarm support from the PDI-P and its long-time leader Megawati Sukarnoputri - a former president who had coveted a return to power - blighted Widodo's early campaign. Many now wonder what influence Megawati will exert over the presidency.
"The campaign indicates there are certain key constituencies he will have to handle very deftly," said Jakarta-based political analyst Douglas Ramage.
Less than two years ago, Widodo was mayor of Solo, a city of 500,000 in Central Java. On Oct. 20, he will be sworn in as president of the world's fourth most populous country.
Despite this meteoric rise, some experts believe he has the skills to run Indonesia after winning plaudits for his business-like management of the teeming capital over the past 18 months and for transforming crime-ridden Solo into a centre for art and culture.
"He might be inexperienced on the national stage, but what we often miss is that he's 53, with a decade of experience in executive positions," said Ramage.
Widodo assumes the presidency at a critical time, with Indonesia's growing confidence abroad matched by an unfulfilled domestic yearning for clean government and a more equitable society.
Indonesia under Widodo will be more "inward-looking, but that's not a bad thing," said Achmad Sukarsono, a political analyst at the Habibie Center, a Jakarta think tank. "We have a president who (understands) our interests, not just the interests of the few elites."
Widodo's campaign got off to a late start. The PDI-P didn't nominate him until mid-March, only then scotching speculation Megawati would run despite losing two previous presidential elections. By contrast, Prabowo's bid was years in the planning.
The rift between Widodo and the PDI-P widened after the April 9 parliamentary election. The party performed worse than expected. Its campaign, run by Puan Maharani, Megawati's daughter and heir apparent to the PDI-P chair, failed to capitalise on Widodo's popularity.
Instead, it promoted the notion that Megawati controlled the party - and, by implication, Widodo. This was a gift to Prabowo, who would urge people not to vote for a "puppet president".
Widodo later told Reuters he respected Megawati. Agitated, he added: "If there is someone who says that I'm a puppet, that is a big mistake."
Even so, Megawati's debatable influence over Widodo was a drag on the campaign. "The party machinery was not working," said the close media advisor, who declined to be identified because of the sensitivity of the issue. "There was no coordination and everyone was just very relaxed."
On May 19, Golkar, Indonesia's second-largest party, unexpectedly threw its support behind Prabowo, and a Widodo presidency no longer felt like a sure thing.
SMEARS AND VOLUNTEERS
A smear campaign was also in full swing. Rumours spread on social media that Widodo, a Javanese Muslim, was an ethnic Chinese Christian - a tough sell in the country with the world's largest population of Muslims.
"The most frustrating part of the campaign was spending 70 percent of our time in Islamic boarding schools, countering the black campaign about Jokowi being ethnic Chinese and Christian," vice president-elect Jusuf Kalla told Reuters in a post-election interview.
As Prabowo gained in the polls, more volunteers got involved. Among them was Melany Tedja, an energy consultant.
She had assumed most educated Indonesians would gravitate towards Widodo. "In fact, surveys showed that the more privileged you are, the more likely you are to vote for Prabowo," she said. "They really bought the whole concept of Prabowo being this firm, tough leader."
Tedja felt the campaign was focusing too much on the folksy affability of Widodo, a former furniture salesman.
"What got lost was that his team is full of people who are strong on economics, energy, foreign affairs," she said.
So Tedja joined an army of volunteers she estimated would swell to two million people. They countered smears and promoted his platform on social media, urging undecided voters to choose Widodo.
When it came to presidential debates, however, Widodo appeared to be on his own. His forgettable performance in the first debate on June 9 was followed by a spiritless one six days later.
Then came the June 16 crisis meeting attended by Widodo, his running mate Kalla, Megawati, her daughter Puan and heads of other parties that supported his candidacy.
They were presented with a poll by the Jakarta-based Centre for Strategic and International Studies (CSIS) showing Widodo's lead over Prabowo had shrunk to 1.8 points.
The results were never published for fear of further eroding that lead, said businessman Wanandi.
Widodo's team "finally woke up", said Wanandi. "They didn't take (winning) for granted anymore. Even Megawati got into action and started campaigning."
While the party machinery had idled, campaign volunteers had become a potent force. On July 5, four days before the election, tens of thousands of Widodo supporters gathered at a Jakarta stadium for a free concert by famous Indonesian musicians.
That "final push" by volunteers helped swing many middle-class voters, said Anies Baswedan, Widodo's spokesman. "(The volunteers) convinced them that they had to be part of this history."
For many Indonesians, Prabowo revived memories of long-ruling dictator Suharto - once his father-in-law - who was overthrown in 1998.
"People realised that if Prabowo became president, the kind of Indonesia they had become used to could disappear," said the close media advisor.
On the evening of July 5, Widodo - wearing his signature checked shirt - was relaxed and confident in the third and final presidential debate, while Prabowo looked flustered.
Campaigning was forbidden by law for three days before the election. Widodo made a quick trip to Mecca, helping silence those who questioned his faith.
President-elect Widodo faces huge expectations, particularly from ex-campaign volunteers. "Because we made this happen, it's like we are the government," said Melany Tedja.
As a candidate, Widodo has promised to avoid shady political horse trading and appoint a technocratic cabinet. Keeping that promise will be tough.
"Already there are people in the coalition screaming, 'Why am I not in the transition team? I want this or that ministry!' Jokowi has to deal with that pressure," a member of Widodo's transition team told Reuters.
A senior campaign advisor insists Widodo's victory has prompted "a fundamental shift" in his relationship with Megawati.
"He has delivered a victory she could only dream of," he said. "That gives him a lot of power, and with that kind of power you can't be pushed around."
(Writing by Andrew R.C. Marshall; Editing by Dean Yates)