But his Suharto-era opponent, Prabowo Subianto, said other data indicated he had won.

Mr Widodo is the first candidate in direct elections with no connection to former dictator Suharto's 1966-1998 regime and its excesses.

The quick counts tally a representative sample of votes cast around the country and have accurately forecast the results of every Indonesian national election since 2004. It will be around two weeks before votes are officially tallied .

This is "not a victory for the party, not a victory for the campaign team, but this is a victory for the people of Indonesia," Mr Widodo, known by his nickname Jokowi, told supporters from a historical site in Jakarta where the nation's independence was declared.

Hundreds of his supporters later celebrated at a famous traffic circle in the capital, waving flags and setting off fireworks.

But Mr Subianto - a general in the Suharto regime and the late dictator's former son-in-law - said he had different quick-count data showing he had won.

"Thank God, all the data from the quick counts shows that we, Prabowo-Hatta, gained the people's trust," he told a news conference, referring to his running mate Hatta Rajasa.

"We ask all the coalition's supporters and Indonesian people to guard and escort this victory until the official count," he added.

Outgoing president Susilo Bambang Yudhoyono urged both camps to "restrain themselves" and not allow their supporters to publicly declare victory until the election commission decides the winner.

Mr Widodo, despite a lack of experience in national politics, is seen as a man of the people who wants to advance democratic reforms and is untainted by the often corrupt elite that has run Indonesia for decades.

Mr Subianto had a dubious human rights record during his military career but is seen as a strong and decisive leader.

Just a couple of months ago, the election was considered firmly tilted towards Mr Widodo, 53, who rose from humble beginnings to become the governor of Jakarta in 2012.

But Mr Subianto, 62, led a late surge after picking up the endorsement of most of the country's largest and well-organised political parties and running an efficient ground campaign.

Natalia Soebagjo, chair of Transparency International's executive board in Indonesia, said it was reckless for either candidate to declare victory before the official results.

She said the three most reputable quick-count results showed Mr Widodo as the leader and she did not trust the surveys Mr Subianto had cited.

"If this continues, I predict in the next 10 days we might see trouble," she said. "They can contest it in legal terms and in social terms by creating unrest.

"It all depends on what these candidates really want. Is their thirst for power so great that they would want to fight it out to the death?"

The two candidates are vastly different in their policies and styles. Mr Widodo is a soft-spoken man who likes to wear trainers and casual check shirts, listen to heavy metal music and make impromptu visits to the slums.

Mr Subianto is known for his thundering campaign speeches, a penchant for luxury cars and having trotted up to one campaign rally on an expensive horse.

The campaign period was marred by smear tactics from both camps. Mr Widodo blamed his fall in opinion polls on character assaults that accused him, among other things, of not being a follower of Islam. He has denounced them but says it is hard to undo the damage it caused.

Mr Subianto's campaign has been more effective and better financed. He also enjoyed the support of two of the country's largest television stations.

But his past, including ordering the kidnappings of pro-democracy activists prior to Suharto's fall in 1998, has not gone unnoticed and some voters fear a return to the brutal dictator's New Order regime.

The election - Indonesia's third direct presidential vote - has played out with fury in the social media-crazed country. There has been a frenzy of "unfriending" on Facebook pages belonging to users who support different camps.

Later, Mr Subianto told supporters his opponent went too far by giving a victory speech, saying "a true warrior does not need to show off his strength".