Jakarta's Christian Governor, Basuki Tjahaja Purnama, better known as Ahok, has lost the governor's election in a landslide, according to unofficial results.
The so-called "quick counts" of the votes have shown Ahok's rival, a Muslim and a former education and cultural Minister, Anies Basweden surging ahead and likely to win by a massive margin.
Anies Baswedan had secured with around 58 per cent versus 42 per cent of the vote for Ahok, according to the quick counts.
Although the official figures won't be known for some weeks, the quick counts, conducted by polling agencies, research companies and television stations, have historically proven accurate.
Anies Basweden all but claimed victory on Wednesday when he fronted the press with his team.
"For us the journey is still long, our effort is not just winning the election but our main aim is to bring back social justice for Jakartans," he said.
"We are also committed to maintain the pluralism of Jakarta and restore the oneness of Jakarta."
Opinon polls in the lead-up to the count had shown the contest was too close to call.
On Wednesday Ahok will return to the North Jakarta District court, where he is facing up to five years in prison for blasphemy.
His supporters say the charges of insulting Islam are politically motivated and aimed at ending his political career.
Anies Basweden will be sworn in as Jakarta's new Governor in October.
People were taken into custody for polling booth conduct
There had been concern the election could spark unrest, and police in the capital were prepared to respond.
The campaign has been one of the most bitterly fought elections the city has ever seen, and the election is being seen as a test for religious tolerance and pluralism in the majority Muslim nation.
Jakarta's police chief Mochamad Iriawan confirmed a number of people were taken into custody for their conduct at some polling booths in the city.
He said in one case a group had tried to break into a polling booth, but gave no further detail.
In Petamburan in central Jakarta a small crowd stood quietly to hear the votes read out.
The booth is unique as it is home to the headquarters of the radical group the Islamic Defenders Front, that has led the campaign against the current governor, but is also heavily populated by Christians.
Police had warned against intimidation of voters, with some ultraconservative Islamic groups threatening to guard booths.
They argue Muslims are prohibited by the Koran from voting for a non-Muslim leader.
Inspector General Iriawan said he was also investigating reports that one booth did not have enough ballot papers.
President calls appeals for unity on poll day
After casting his ballot, President Joko Widodo urged voters to accept the result.
"Whatever the result is, whoever gets elected, we have to accept it with big hearts," Mr Widodo said.
"I believe that democracy, the governor's election is going well and will produce a leader of Jakarta that is best and trustworthy," he said.
"The difference in politics should not break our unity. We are all brothers."
Voters spoken to by the ABC expressed their relief to have cast their ballots, but most said they were anxious about the result.
"I feel relieved after I voted, I hope Jakarta is more beautiful, is a better Jakarta," one woman voting at the president's polling booth said, holding her ink-stained finger high.
"I feel my heart beating expecting the result, I'm guessing who will win," another woman said, although not revealing her vote
"That's a secret," she added.
"Surely Anies will be the winner," a male voter said.
"I believe that the choice depends on the person but I believe Jakartans have grown smarter voters, whoever they choose they will be responsible for that."