JAKARTA (Reuters) - Indonesia's young democracy faces its biggest challenge since emerging from decades of autocratic rule 16 years ago after both candidates claimed victory in last week's presidential election.
It will be up to two key institutions, both with bruised reputations, to decide which of the two men who contested the July 9 poll has the right to move into the white-pillared presidential palace in central Jakarta and lead the world's third biggest democracy for the next five years.
The first will be the Elections Commission, hit by graft charges in the past, and which is now in the process of checking the vote count before it announces the final result by July 22.
The camps of the rival candidates - Jakarta Governor Joko "Jokowi" Widodo and former general Prabowo Subianto - have made none-too-subtle suggestions that the other might cheat in the time it takes to declare the official result.
Despite the tensions, there has been no violence, although that is a worry. Hundreds of people were killed in violence that swept the vast archipelago when ironman ruler Suharto was ousted in 1998 after over three decades in office and a shaky but functioning democracy put in his place.
No presidential election, and this is only the third through direct voting, has been so close, or so bitter, since Indonesia declared independence in 1945. But officials and poll observers say it is not easy to cheat, given the institutional safeguards that have been built in.
"At the (village) level, that is the place where you can exercise the most effective fraud. It's not easy because you have prominent pollsters saying what the result is," one international election observer said, noting that there are five levels of vote tabulation from the village to national level. He declined to be identified because he was not authorized to speak to the media.
Quick vote counts by private groups, which have proven very accurate in the past, put Jokowi ahead by around five points against Prabowo, although the former special forces general has rejected the tallies.
"What's clear is that seven credible pollsters have released their quick count results. That can be (used)...Even though it's not official," Jokowi told Reuters.
Prabowo's camp says those pollsters deliberately skewed the quick count in favour of Jokowi and that its own counts put Prabowo just ahead.
Based on the counts, which provide a sampling of the roughly 130 million votes cast, analysts estimated the losing side would need to fraudulently reverse 6.5 million or more votes to come out on top.
"You would have to mass manufacture votes at the village level which is hard because of the amount of scrutiny there is," the election observer said.
Votes are counted on election day in public and in daylight.
Overseeing that process is the Elections Commission (KPU)which has had brushes with graft scandals in the past but which is now see as clean enough to come up with a valid result.
"The KPU is the best we've had," said Asia Foundation's Indonesia head, Sandra Hamid, adding that the openness of voting data made it very hard the fiddle with the result.
Transparency International Indonesia too doubted the KPU result would be subject to fraud.
"A lot of the mistakes of the Elections Commission has been related to capacity and administrative work that has been sloppy rather than by design wanting to subvert the system. I don't think anyone in the commission would want to do that." the group's chairwoman, Natalia Soebagjo, said.
Outgoing President Susilo Bambang Yudhoyono has told both candidates to keep their supporters off the streets.
Calm has been encouraged by placing about 250,000 police on alert across the archipelago and by the Islamic fasting month of Ramadan in a country that is home to the world's largest Muslim population.
Once the result is out, the losing side is likely to launch a challenge in the Constitutional Court which has final say over contested elections and is the other key institution that is in the spotlight.
But the court's reputation is in tatters after its last head was sentenced this month to life in jail for corruption which some analysts said was probably enough to ensure that this time it would go out of its way to look squeaky clean.
"If it wants to restore its credibility, it must ensure that once a dispute does arise it handles it properly and (judges) ... forget their political affiliations because many of those in the court right now have past political affiliations," said Transparency's Soebagjo.
Asked if Prabowo might appeal to the Court, his brother told Reuters: "Yes, we're keeping that option open. Potentially this could go on...for several weeks anyway."
The court's new chief justice, Hamdan Zoelva, said it was ready for any challenges.
"I hope there will be no need to bring the election result to the Constitutional Court," he told Reuters. "If it is brought to us...the court will aim for a unanimous decision. But if that is impossible to reach, then they will have to settle with a majority ruling.
"We will, to our utmost, independently and professionally treat every party equally. We will carefully and thoroughly resolve the case. That is all we can do."
The candidates have 72 hours after the official result to lodge a complaint with the Court. A decision, which cannot be appealed, much be reached by a panel of nine judges within 14 days.
Zoelva's appointment has come under criticism over his past as a politician. The party he belonged to supports Prabowo. An earlier and popular head of the Court, Mahfud MD, is a prominent member of Prabowo's team.
But the lawyer who would represent the Jokowi camp in any election case in the Constitutional Court, called the MK, said he was confident its verdicts would be neutral.
"This is the time for the MK to prove to the people that they are a credible court. I don’t think they will disappoint. (Former chief justice) Mahfud MD may have influence but the future of the nation, the accountability to the people, the due process of law is far more important than loyalty to the former chief justice," said Todung Mulya Lubis.
"The stakes are too high."
(Additional reporting by Dennys Kapa, Randy Fabi and Jonathan Thatcher, Writing by Jonathan Thatcher; Editing by Raju Gopalakrishnan)