Former Indonesian education minister Anies Baswedan (C) holds the hand of Gerindra party chief Prabowo Subianto (R) with Baswedan running mate Sandiaga Uno (L) in Jakarta, Indonesia April 19, 2017.
Polls suggest it is a close race between incumbent Basuki Tjahaja Purnama, a Christian, and Anies Rasyid Baswedan, a Muslim. Other pollsters showed similar results with 99 per cent counted.
Unofficial results showed he won about 40% of the vote, roughly the same as in the first round of the election in February, indicating that he did not attract additional support in a city that is 80% Muslim.
The campaign featured mass rallies led by a hardline Islamist movement, which has strengthened in recent years in a country long dominated by a moderate form of Islam.
Basuki said the election has highlighted the "conflicted conscience within the Indonesian voter" and has paved the way for political parties to utilise religion and hoax news in the future.
Baswedan compared the poll to the Battle of Badr, a pivotal fight in the early days of Islam that consolidated the Prophet Muhammad's power, a win ascribed to divine intervention.
It's unclear what impact Ahok's loss will have on Joko in the 2019 presidential election. "What I want from a governor is someone who can deliver good results, anti-corruption, firms with all regulations so that we can have a better Jakarta", she said.
After Widodo's 2012 win quickly led to a successful run for the presidency in 2014, Indonesian political insiders now see the Jakarta governorship as a step to the highest office in the land.
Purnama is backed by President Joko Widodo's ruling party.
Security appeared light at several polling stations, though police said 66,000 personnel were deployed across the city.
Many of those who filled the streets of Jakarta to protest against him late a year ago were among the displaced, and violence broke out in Luar Batang after one of those demonstrations.More news: Trump signs executive order targeting specialty work visas: 5 things to know
With 99 percent of quick count vote data entered, it looks as though Jakarta governor Basuki "Ahok" Tjahaja Purnama has reaped the storm of his clumsy comments previous year regarding the Quran whilst campaigning in the capital's Thousand Islands region. One person died and more than 100 were injured after one protest turned violent.
Some voters may have been reluctant to vote for Basukibecause of worries of "five more years of protests on the streets by Muslim hardliners", said Mr Loveard.
Wednesday's election was a test of Indonesia's reputation for religious tolerance.
Prabowo also demanded that people stop saying that kyai and ulama were radical people who meant to commit treason, and expressed his appreciation for Islamic leaders including Rizieq, Habib Ali bin Abdurrahman Assegaf and Islamic People's Forum (FUI) leader Bachtiar Nasyir.
He urged his supporters to remain calm and maintain harmony and unity in Jakarta.
Baswedan and Prabowo were also expected at grand mosque to join the prayers, according to media reports.
Hardline groups have seized on Ahok's background as a Christian of Chinese descent - historic targets in the world's most populous Muslim nation where ethnic tensions have resulted in bloody communal violence. His platform has focused on improving public education and combating the rising cost of living. Millions of Indonesians in the capital Jakarta are elect.
Mr Anies also pointed out that Jakarta is the most diverse city, in terms of ethnicity and religions, in Indonesia.
Basuki congratulated his rival in a news conference.
"We now will come together and forget this campaign". But in Indonesia and especially Jakarta, it's the reverse: all local politics are national.
"As long as there are no security issues, the election outcome should not significantly stall the reform programme of the national government, in our view", it said.