The Jakarta poll has been overshadowed by religious tensions, with mass Islamist-led protests against Governor Basuki Tjahaja Purnama, an ethnic Chinese Christian.
The vote is also being widely seen as a proxy battle for the 2019 presidential election.
Purnama had secured 42.57 percent of the votes, just ahead of former minister Anies Baswedan in second place with 40.23 percent, based on a quick sample count of around 40 percent of the vote by private polling firm SMRC.
The other candidate, Agus Yudhoyono, was in third place with 17 percent. Other pollsters showed similar results.
A candidate needs to get more than 50 percent of the votes in the first round to win outright.
The job of governor can be a springboard to the presidency and weeks of campaigning have been overshadowed by mudslinging, political intrigue and rising hardline Islamist sentiment, raising questions about the role of religion in politics.
"We hope that everybody can return as a family after these elections," President Joko Widodo said after voting in Jakarta.
Purnama was a deputy to Widodo when he was the previous Jakarta governor and Widodo's party is backing him.