Anies Baswedan was on 56-57% in the fight to lead Jakarta compared to 41-43% for Basuki Tjahaja Purnama, who is battling for his job as he stands trial for blasphemy, according to early counts from several private pollsters.
Indonesians vote for Jakarta governor as religious tensions divide
The vote is seen as a test of whether the moderate Islam traditionally practised in the world's most populous Muslim country is under threat from hardliners, who have led mass demonstrations against Purnama.
Purnama, the city's first non-Muslim governor for half a century and its first ethnic Chinese leader, won the first round in February but not by a big enough margin to avoid a run-off.
The race was already significant as politicians see the job as a stepping stone to the presidency at 2019 polls, but the stakes were raised dramatically by a controversy sparked by claims that Purnama had insulted the Koran.
The allegations drew hundreds of thousands of Muslims onto the streets of Jakarta in major protests last year, and led to Purnama - known by his nickname Ahok - being put on trial for blasphemy in a case critics see as politically motivated.
After casting his vote, President Joko Widodo - whose party backs Purnama - urged Jakarta residents to accept the result and for the city to come together after the bitterly fought poll.
"We must not let different political choices break our unity," he said. "Remember, we are all brothers and sisters."
Over 7.2 million people were registered to vote in the polls, which closed at 1:00 pm (0600 GMT).
Official results will not be released until early May but the private pollsters are usually accurate.
After an anti-Purnama protest last year turned violent, authorities were taking no chances and over 60,000 security forces had been deployed.
Hardline groups had pledged to station monitors at polling booths. Police blocked the plan, warning it could cause "intimidation", but groups of hardliners appeared to be outside some polling centres in defiance of the ban.
However, there was no sign of unrest and police said the election had run smoothly.
Despite Purnama's first-round victory, former education minister Baswedan, 47, was seen as the favourite in the run-off because the votes from a third, Muslim, candidate who was knocked out were expected to go to him.
But with tension over the governor's alleged blasphemy subsiding in recent weeks, Purnama has regained momentum and recent polls showed the candidates in a dead heat.
Indonesians vote for Jakarta governor as religious tensions divide
Baswedan, an academic who was sacked from the government by Widodo, has been accused of abandoning his moderate Islamic values during the campaign by cosying up to hardliners to try to win the support of Muslim voters angered by Purnama's alleged blasphemy.
Purnama's troubles began in September when he light-heartedly said in a speech that his rivals were tricking people into voting against him by using a Koranic verse, which some interpret as meaning Muslims should only choose Muslim leaders.
His long-running blasphemy trial began in December, and the verdict is expected within a few weeks.
If he does win the vote and is convicted of blasphemy, he would not automatically be barred from holding office and could avoid jail for a long time by appealing.
Many voters still support Purnama due to his record leading Jakarta since 2014. He has won praise for cleaning up once-filthy rivers and creating more green spaces, although his acerbic style has upset some.
"I voted for Ahok because I'm poor and I have felt the difference - we're being taken care of," said Tayem, a 62-year-old housewife who like many Indonesians goes by only one name, after casting her ballot.
But some have been swayed by the blasphemy controversy.
"As a Muslim, I will choose according to my faith," Elva Sativia, a 33-year-old housewife said.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ