Jakarta's Christian governor Basuki Tjahaja Purnama (C), better known as "Ahok", flanked by his wife Veronica (R) and son Nicholas (L) show off their ballot papers in Jakarta on February 15, 2017
Jakarta's Christian governor was heading for a tough run-off against a Muslim opponent in city elections seen as a test of religious tolerance in Muslim-majority Indonesia after a tight first round Wednesday.
Basuki Tjahaja Purnama held a narrow lead, according to private pollsters, despite being on trial for blasphemy, but is seen as unlikely to win in April's second round against ex-education minister Anies Baswedan, who came a close second and will attract more Muslim votes.
Third candidate Agus Yudhoyono, another Muslim challenger and the son of a former president, trailed far behind.
Baswedan said "Thanks be to God!" on hearing he looked on course to become governor of the megacity of 10 million -- but Purnama, who has won support with his determination to clean up Jakarta, signalled he was ready for a fight.
"This is not over yet," he told cheering supporters at his campaign headquarters in Jakarta. "Some pollsters said we were the candidates no one would vote for," he said, referring to himself and his running mate. "We ended up in the lead."
Over 100 polls to elect local leaders were taking place across Indonesia Wednesday but the race in the capital was the most hotly contested, with the top job in Jakarta seen as a stepping stone to victory in the 2019 presidential polls.
The stakes in the vote have been raised by allegations that Purnama -- the city's first non-Muslim governor for half a century and its first ethnic Chinese leader -- insulted the Koran.
The claims drew hundreds of thousands of conservative Muslims onto the streets of Jakarta in major protests last year, and Purnama has been put on trial in a case criticised as unfair and politically motivated.
Purnama, known by his nickname Ahok, was not barred from running but his popularity was dented for a period. The vote is now seen as a test of whether pluralism and a tolerant brand of Islam in the world's most populous Muslim-majority country are being eroded.
- 'Needs a miracle' -
Once the favourite to win the gubernatorial election, Purnama was on about 43 percent to Baswedan's 39 in Wednesday's first round, meaning no candidate had passed the threshold needed to avoid a run-off, according to early vote tallies by private pollsters.
The official results are not expected for a few weeks but the early tallies, called "quick counts", are generally thought reliable.
Despite his upbeat remarks, analysts warn Purnama is unlikely to win a second round against a candidate who has appealed to voters disillusioned by the governor's alleged blasphemy and controversially courted a hardline group that organised the protests against him.
"At this stage, it will be a miracle if Ahok wins," said Tobias Basuki, a political analyst from Jakarta think-tank the Centre for Strategic and International Studies, adding it was unlikely the first round votes for Yudhoyono would go to Purnama.
Observers also warn that any run-off between Purnama and Baswedan could stoke religious tensions further after months of a dirty campaigning.
"The tense situation will continue until April -- this kind of thing is dangerous," said Burhanuddin Muhtadi of pollster Indikator.
Campaigning was marked by a flood of "fake news" which has mainly targeted Purnama, and included claims that a free vaccination programme he backed was a bid to make girls infertile and reduce the population.
In the event that Purnama wins and is convicted of blasphemy, which could see him sentenced to up to five years in prison, he would not automatically be barred from holding office and could avoid jail for a long time by filing successive appeals.
Purnama's troubles began in September when he 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.
The controversy is a high-profile example of the religious intolerance that has become more common in Indonesia, 90 percent of whose 255 million inhabitants are Muslim.
Purnama won popularity for trying to improve traffic-choked and chaotic Jakarta by cleaning up rivers and demolishing red-light districts, although his combative style and controversial slum clearances sparked some opposition.