Thousands of soldiers fanned out across Jakarta on Tuesday as unexpectedly early results in Indonesia's election showed Joko Widodo was re-elected leader of the world's third-biggest democracy.
The election commission had been due to announce the final tally of the divisive poll on Wednesday, but the results were revealed early Tuesday with little advance notice amid fears of unrest.
Presidential challenger Prabowo Subianto had warned of possible mass uprisings in response to his claims of widespread cheating.
Tensions have also spiked high since police said last week that they arrested dozens of Islamic State-linked terror suspects -- including some who planned to cause chaos by detonating bombs at any post-election protests.
On Friday, the US embassy in Jakarta issued a heightened security alert for Indonesia, the world's biggest Muslim majority nation.
There was a heavy security presence in Jakarta on Tuesday, including in front of the elections commission office, which was barricaded with razor wire and protected by scores of heavily armed troops.
Subianto, a 67-year-old retired general, has targeted the commission by accusing it of allowing a string of election violations.
The former military man -- who has strong ties to the Suharto dictatorship that collapsed in 1998 -- has kept up a steady string of rhetoric since unofficial results for the April 17 poll put bitter rival Widodo ahead by a wide margin.
Subianto lost a 2014 presidential battle with Widodo, which he unsuccessfully challenged in court.
It was not immediately clear if he would formally challenge the latest results. However, Azis Subekti, a witness for Subianto's camp, refused to sign the official election results Tuesday, and hinted that the matter was not settled.
"We won't surrender in our fight against injustice, fraud and abuse," he was quoted as saying by Indonesia's Detik.Com.
Analysts and election officials have discounted Subianto's claims that the result was affected by voter fraud and widespread cheating.
"The scale of abuses and errors in the conduct of the election are clearly very minor overall," Jakarta-based political analyst Kevin O'Rourke said before Tuesday's official results.
"(Subianto) and his camp are harping on minor deficiencies and very micro problems, clearly in an attempt to sway public opinion and delegitimise Widodo." It was unclear if huge crowds would flood the streets to support Subianto, but there was little sign of Tuesday.
"There will be protests from disappointed (Subianto) supporters but I don't think it'll be significant," said Syamsuddin Haris, a political analyst at the Indonesian Sciences Institute.
"Authorities have been anticipating this," he added.
The presidential campaign was punctuated by bitter mudslinging and a slew of fake news online -- much of it directed at the presidential contenders.
The soft-spoken Widodo -- who pointed to his efforts to boost Southeast Asia's biggest economy with a huge infrastructure push -- stood in stark contrast to fiery nationalist Subianto, a strongman who courted Islamic hardliners and promised a boost to military and defence spending.
Online, Subianto was pilloried by social media users who poked fun at his repudiation of the unofficial results and for kissing the ground as he declared himself president.
Last month, a record 245,000 candidates ran for public office in Indonesia, from the presidency and parliamentary seats to local positions -- the first time all were held on the same day.
Widodo and his vice-presidential running mate Ma'ruf Amin won the country's top jobs with 55.5 per cent of the vote against 44.5 per cent for Subianto and his wealthy financier partner Sandiaga Uno, the commission said Tuesday.
Some 85.6 million votes were cast in favour of Widodo out of about 154 million in total, it added.
Widodo scoring thumping victories in holiday hotspot Bali and heavily populated East Java, while Subianto landed big wins in conservative Aceh and West Java.