"The votes may have shifted from Yudhoyono to Baswedan," said Irine Gayatri, a political analyst at the Indonesian Institute of Sciences.
Ethnicity and religion would likely again be major issues in a second round, Gayatri said.
The president said he hoped for an easing of tension.
"We hope that everybody can return as a family after these elections," Widodo said after casting his vote.
Purnama, dressed in his signature checkered shirt, met cheering supporters at his campaign headquarters.
"The struggle is not over," he told them. "Everyone wants just one round but we're grateful to have come at least this far."
Baswedan said his campaign for a second round would focus on policies.
"We will focus on programmes, about jobs, about quality education, needs that are important and urgent for families and people in Jakarta," he told reporters.
The votes in Jakarta and scores of other regions in the world's third-largest democracy were peaceful and mostly running without hitches, police said.
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.