Indonesian President Joko "Jokowi" Widodo comfortably won last month's presidential poll, an official count showed, but the refusal of his opponent Prabowo Subianto to concede defeat has triggered the prospect of both a legal challenge and street protests.
The General Election Commission (KPU) confirmed counts issued by private pollsters that showed incumbent Jokowi won the April 17 election by 11 percentage points.
Independent observers and analysts have said the poll was free and fair, but Prabowo and his campaign team have alleged "massive cheating and irregularities" during the vote and vote-counting.
WHAT LEGAL OPTIONS DO CANDIDATES HAVE?
A campaign official for the opposition said Prabowo would challenge the election result in the Constitutional Court, which has to be within 72 hours of the KPU announcement.
If the court finds enough evidence to take the case, it must make a ruling within 14 days after all documents are provided by the plaintiff. The decision cannot be appealed.
The KPU's timeline to resolve the dispute is between May 23 and June 15. It will declare a final election result, or a dismissal, within three days of the court ruling.
"The court could decide to reject or grant the applicant's request, in full or in parts," said court spokesman Fajar Laksono.
"There is a chance that the court could order the KPU to hold a recount or a re-polling ... but again, it depends on evidence presented during trial," he said, adding that the winner must be sworn in by October.
Indonesia's election supervisory panel (Bawaslu) has dismissed two official complaints of election cheating on the grounds of insufficient evidence.
Prabowo also launched a legal challenge to his 2014 defeat by Widodo, which was rejected, and there were doubts that he would pursue this tack again. He recently told foreign correspondents "we cannot hope to find real justice there".
WHAT ARE THE PROSPECTS OF STREET PROTESTS?
The retired general has said the situation could trigger "people power"-style protests, while the government and police have vowed action against anyone stirring up unrest.
Even if a legal path is followed, there is a risk that Prabowo's supporters could still launch protests, paralysing parts of the capital.
On Tuesday, Prabowo urged his supporters to maintain public order and peace during demonstrations.
WHAT ARE THE LONGER-TERM POLITICAL RISKS?
Analysts have said the double-digit margin of Widodo's victory meant the opposition does not appear to have a strong case to claim the election was rigged.
Still they noted risks that Islamist supporters of the challenger, including the hardline Alumni 212 movement, could cause considerable disruption.
Islamist groups, many of which support Prabowo, have in the past been able to mobilize hundreds of thousands of supporters.
From late 2016, they organised a series of protests against then-Jakarta governor Basuki Tjahaja Purnama, the first ethnic-Chinese Christian to hold the job, who was subsequently jailed for insulting the Koran.
In a bid to take the sting out of protests, chief security minister Wiranto has ordered police and military to prevent people from travelling to Jakarta en masse.
Indonesia's biggest Islamic group, Nahdlatul Ulama, has also urged people to avoid rallies, saying its mosques would not accommodate protesters from outside the capital, except for prayers, media said.
But with police questioning at least three opposition figures for suspected treason and Widodo already facing accusations of turning authoritarian, a too-heavy-handed approach could also backfire.
Achmad Sukarsono, a political analyst at Control Risks, said given how Widodo mostly won in provinces with more diverse religious populations, he would need to placate some of Prabowo's Muslim supporters "to reunite the nation and heal the wounds from the most divisive election in Indonesia's democratic history".
This could include conceding to "soft demands from the Islamic community, such as an equitable economy that is more congruent with sharia principles", he said in a recent note.