Joko Widodo has been declared the winner of Indonesia’s Presidential election and will take office in October.
The election commission has declared that Mr Widodo won the poll with almost 71 million votes or just over 53 per cent.
The former military general Prabowo Subianto received 62.5 million votes or 46.8 per cent.
Mr Subianto had thrown the final declaration into confusion with an attempt to withdraw from the process at the 11th hour.
Some supporters had even suggested he was no longer an actual candidate.
But the Commission’s declaration indicates his status was unchanged.
Ahead of the announcement, Indonesian Democratic Party chairwoman Megawati Sukarnoputri claimed victory for at a news conference in Jakarta.
“I want to declare that we, the party that supports and puts forward Joko Widodo and Jusuf Kalla (for vice president), has won,” she said.
Last minute confusion
Earlier in the day as Indonesia announcement drew closer, Jokowi’s opposition candidate Prabowo Subianto moved to withdraw his candidacy, calling the election process undemocratic.
Mr Subianto – who had also claimed victory in the July 9 election – alleged “massive fraud” and said he was withdrawing from the race to lead the world’s third-biggest democracy.
“There has been a massive, structured and systematic fraud in the 2014 elections,” Prabowo said.
“The presidential election, organised by the (election commission), is not democratic,” he told reporters, adding the commission was “not fair or transparent”.
Prabowo, 62, had been widely expected to challenge the result in the Constitutional Court if he lost, but a spokesman for his team said this was no longer an option since they had withdrawn from the whole process.
The decision removes the prospect of prolonged political deadlock, since the court would not have ruled until the end of August.
If Mr Widodo’s victory is confirmed, it would cap a meteoric rise for the former furniture exporter who was born in a riverbank slum, and would be welcomed by investors who hope he can breathe new life into the economy after a recent slowdown.
With the Jakarta governor’s victory looking assured, Mr Subianto repeated allegations of massive cheating by his opponent and announced he was pulling out of the election process.
Tensions have risen sharply since election day as each side accused the other of seeking to tamper with the votes during the lengthy counting process across the world’s biggest archipelago nation.
There are fears the tension could spark unrest in a country that was hit by repeated outbreaks of violence before Suharto’s downfall in 1998, and more than 250,000 police were deployed across the country on Tuesday.
Security was particularly tight in the capital Jakarta, with hundreds of police in riot gear stationed around the election commission headquarters, and roads around the centre of the capital closed off to traffic.