Anies Baswedan, centre, is mobbed by the press after casting his vote. Credit:AP Mr Prabowo, who was defeated by Joko Widodo in the 2014 elections, has signalled he intends to re-stand for president in 2019. On the eve of the election, Mr Anies compared the gubernatorial election to the Battle of Badr in 624 CE, considered a turning point in the Prophet Muhammad's struggle to establish Islam and defeat his pagan opponents. "Tonight's meeting, heading towards the Badr war tomorrow, at the time the Prophet said that help from God will arrive if our intention to go to the war is to fight for the poor, to defend the oppressed," he was quoted saying in the media. President Joko Widodo, who is an ally of Ahok but said he would remain impartial during the elections, urged Jakartans to willingly accept whomever was voted leader.

Women show their ink-stained fingers after voting during the runoff election in Jakarta. Credit:AP "Political differences between us should not divide our unity because we must remember we are all brothers and sisters," he said while casting his ballot in Central Jakarta. Mr Anies and Mr Sandiaga embraced after learning of the early count results, a sample of final results from polling stations, which are generally a reliable prediction of election outcomes. Jakarta Governor Basuki Tjahaja Purnama, known as Ahok, right, with his wife Veronica and son Nicholas at a polling station in Jakarta. Credit:Jefri Tarigan "We are committed to safeguard diversity and to fight for unity at the same time."

Mr Sandiaga said: "We are all friends. Jakarta is united. We will forget the months that have passed, we will look at Jakarta for the next five years." An electoral worker writes down votes during the runoff election in Jakarta. Credit:AP A remarkably upbeat and philosophical Ahok congratulated his opponents but said they would wait for the formal result. He said he hoped Mr Anies and Mr Sandiaga would complete the programs he had started. Indonesian President Joko Widodo and his wife Iriana cast their ballots. Ahok first became Jakarta's deputy governor on a ticket headed by Mr Joko. Credit:Jefri Tarigan

"We will forget all the problems we had during the campaign. Jakarta is the home for everybody." Ahok said God gave power and took power away. Electoral workers help an elderly woman cast her ballot at a makeshift polling station under a bridge. Credit:AP Eight months ago Ahok's victory in the gubernatorial elections seemed assured. His brash, take-no-prisoners approach in City Hall made him some enemies including among those who were evicted or opposed the Jakarta Bay reclamation.

An Indonesian woman casts her ballot. Credit:AP However he was widely admired for his tough stance on corruption and can-do attitude to flood mitigation, overhauling a stodgy bureaucracy and addressing Jakarta's traffic woes and polls found the majority were satisfied with his performance as governor. But Ahok's destiny was forever changed last September when he told voters they had been deceived by opponents who used a scripture from the Koran - Al-Maidah - to argue Muslims should not be led by a non-Muslim. The ill-advised comments were seized on by Ahok's opponents, including the radical Islamic Defenders Front (FPI). Ahok was put on trial for blasphemy amid mass rallies calling for his incarceration that threatened the political stability of the capital.

Mr Anies, a former university rector and education minister who had a reputation as a moderate Muslim, has been accused of running a dog-whistle campaign by controversially reaching out to hardline groups like the FPI. Religion was omnipresent during the election campaign. Politics even infiltrated schools: Dilla Rosa, a 43-year-old Muslim housewife, told Fairfax Media she was disturbed when her Grade 5 son came home and said his religion teacher had told students they had to elect Muslim leaders. "Politics was taught there - for elementary students it is not appropriate. The school wasn't even in Jakarta," said Ms Dilla, who voted for Ahok because he had "clear programs and real results". Telling children how Muslims should vote "put pressure on them" if their families had different beliefs. "It was upsetting."

At 4am on voting day, Fairfax Media went to Al Azhar, a mosque in South Jakarta. This was where organisers behind Tasmaya Al-Maidah - an app that urged Muslims from outside Jakarta to uphold Islam by "guarding" polling booths - had held a press conference on Monday. The police had banned the mass mobilisation but Tasmaya Al-Maidah committee member Gimy said they were powerless to prevent them. But the police conducted "sweeping" raids of buses on Jakarta's borders, and the 500 expected to assemble at Al Azhar were no-where in sight. About 30 people listened to a moderate sermon, during which the Imam prayed for a peaceful election. Indonesia's police chief Tito Karnavian said the election had run smoothly with no major incidents. Isolated complaints by Ahok supporters of intimidation at polling booths were "misunderstandings", he said, that had been exaggerated by the media. On Thursday, the embattled Ahok must meet his next Waterloo, when prosecutors make their sentence demand for his alleged blasphemy.

He faces being jailed for a maximum five years. However the sting will have been taken out of the court case and its attendant protests, which at times threatened political stability, following Wednesday's election loss. With Karuni Rompies and Amilia Rosa Follow Jewel Topsfield on Facebook