Jakarta: Former Indonesian general Prabowo Subianto said he rejected the presidential election process as unfair and that he was withdrawing from the contest as nearly complete results showed his opponent leading with 52 per cent of the vote.

The announcement came as the Election Commission was finalizing the tally of the July 9 election and preparing to declare a winner later Tuesday. Thousands of policemen were deployed around the commission’s building in downtown Jakarta to maintain security after a particularly nasty presidential campaign.

Jakarta governor Joko Widodo, nicknamed “Jokowi” and known for his common man image, has maintained a slim lead of about 4 percentage points in unofficial “quick counts” by polling agencies released after the election.

But Subianto, who has declared assets of $140 million and is on his third bid for the presidency, has repeatedly claimed that polling firms with links to his campaign showed he was ahead.

After meeting with leaders of his coalition parties Tuesday, he declared that there was massive fraud during the election and that it was undemocratic.

“We reject the 2014 presidential election which is unlawful and therefore we withdraw from the ongoing process,” Subianto said. He ordered his witnesses to leave the commission building where the officials were counting votes from the final five provinces.

The presidential campaign was Indonesia’s ugliest since the Muslim majority country of 240 million emerged from the long and brutal Suharto dictatorship 16 years ago. Supporters of both men used social media for personal attacks, and Subianto’s supporters led a smear campaign against Widodo, spreading unfounded rumours he is not a Muslim.