This article is more than 6 years old

This article is more than 6 years old

A historic presidential election in Indonesia was precariously balanced on Wednesdayafter both candidates declared themselves winners, raising the prospect of a tense standoff in the Islamic world's biggest democracy.

Just hours after the polls closed, Joko Widodo, the governor of Jakarta who has made the fight against corruption and social injustice key policies, gave a live television address claiming victory, setting off scenes of jubilation among his supporters.

"We are grateful that based on the counting of the quick counts, Jokowi-JK has won," he said, referring to his own nickname and the initials of his running mate, Jusuf Kalla. He cited one of the early post-election counts, which samples votes from around the country and which gave him about 52% of vote compared with about 48% for his rival, Prabowo Subianto, an ex-general and son-in-law of the former dictator Suharto.

"This is the victory of all people of Indonesia," Jokowi later told supporters. Another credible quick count by the pollster Saiful Mujani with similar figures gave Jokowi 52.95% and Prabowo 47.05%.

But his opponent was in no mood to concede, appearing on television later to say: "We are grateful from the incoming data that we received the mandate of the people."

Numerous quick counts cited on television channels showed significant variations in result, depending on the political affiliation of the TV channel. The quick counts conducted by the Centre for Policy Studies and the Indonesia Voice Network, put Prabowo in front by 1% to 4%.

Political analyst Yohanes Sulaiman said: "I think basically we are going to be in limbo. Are you actually willing to tell Prabowo to his face: 'Hey, you are wrong'?"

Prabowo, who was dismissed from the Indonesian army special forces for ordering the kidnapping of pro-democracy activists in 1998, is known to have a short temper.

His supporters admire him for his firmness, arguing that Indonesia, a nation strung across 17,000 islands and home to hundreds of ethnic groups and cultures, needs a strong, unifying leader.

Other analysts believe the dual claim could end up in a long drawn-out constitutional battle that is unlikely to be resolved for months.

The elections are seen as a crucial test of democracy in the world's fourth most populous country, as they should result in Indonesia's first democratic transfer of power from one elected leader to another. Indonesia has offered a respectable example, in recent years, of a Muslim-majority country that threw off dictatorship and blossomed economically under a democratic system.

On his official Twitter account, the outgoing president, Susilo Bambang Yudhoyono, who has publicly endorsed Prabowo, urged for peace to be preserved.

He asked both camps to "restrain themselves and not to mass on the streets to celebrate, until an official KPU [election commission] announcement".

Yudhoyono repeated his comments several hours later, adding that the conflicting counts did not qualify as the "official results".

Authorities said up to 250,000 police officers were on standby across the country and while there are fears that the conflicting declarations could cause unrest, as of Wednesday evening there were no reported incidents.

Before the election several credible pollsters had placed Jokowi ahead of Prabowo, but maintained that the race was too close to call.

At the polls, voters appeared to be equally divided over their choice of the next president.

Voting preferences were more pronounced across demographic lines. First-time voters, who account for a third of the 187 million electorate, tended to favour Jokowi.

Anis Komariah, 28, commenting on Jokowi's reputation for clean governance as she voted in south Jakarta, said: "He is the type of person that is sincere, and the parties that support him, he didn't offer them ministerial positions."

Young voters, who have taken to social media in huge numbers during the election – at one point on Wednesday six out of 10 top trending hashtags worldwide referred to Indonesia's election – believe that Jokowi represents a clean break with the past.

Older voters who are likely to have vivid memories of the mass riots that led to the fall of Suharto in 1998, say they favour Prabowo, seeing him as a strong, commanding leader who they believed would better unify the country.

Rofiq Mohammad, a 48-year-old voter, said: "I think a strong leader is important because we don't want a situation like the Middle East.

"If things get unstable, everything will go bad and maybe so bad that it will be difficult to come back again. Indonesian stability is the most important."

However, there appeared to be a consensus among voters in the world's third-largest democracy that the election should go ahead peacefully amid fears that riots could break out in the event of a tight or contested result. Official results are not expected for two weeks.

Edward Gunawan, a film producer who flew home to Indonesia from Bangkok in the middle of a shoot so he could vote for the first time, said that in recent weeks selfies and pictures of food had vanished from his social media feeds.

"It's interesting that your news feed is suddenly filled with very serious stuff, but I see it as a very encouraging sign," said Gunawan, who likened the mood to the election of US president Barack Obama in 2008. "My generation and even the younger generation are getting involved and getting excited about the political process."