Image copyright AFP Image caption Tens of millions of Indonesians have been voting in regional elections

Residents of the Indonesian capital, Jakarta, have voted for a new governor, in an election overshadowed by the incumbent's blasphemy trial.

Basuki Tjahaja Purnama, or "Ahok", is the first Christian and ethnic Chinese leader of the majority Muslim city in over 50 years and is running again.

He is also on trial for insulting Islam, after he accused his opponents of using the Koran to mislead voters.

Tens of millions of Indonesians have also voted in regional elections.

Private polling after the vote ended suggested Mr Purnama held a narrow lead, ahead of former education minister Anies Baswedan, but below the 50% margin needed to avoid a run-off vote, which would be held in April.

Official results are due in late February.

Image copyright Reuters Image caption The capital has seen huge rallies against the governor

Elections were held for the leaders of seven provinces, 18 cities and for the local leaders of 76 districts. The election in Jakarta is seen as a test of religious tolerance in Indonesia, the world's most populous Muslim nation. About 85% of the population are Muslim, but the country officially respects six religions.

It is Mr Purnama's first electoral test as governor, a role he stepped into from the deputy position in 2014 when then-governor Joko Widodo became president.

He was seen as the favourite to win - and as a potential future president - until he was charged with blasphemy in late 2016, a criminal offence in Indonesia.

Image copyright AFP Image caption "Ahok" is known for his checked shirts, often also worn by supporters

Image copyright EPA Image caption The full results of the election are not expected until the end of the month

The case centres on comments he made to voters in pre-campaigning, advising them not to be fooled by religious leaders who told them Muslims should not be governed by a non-Muslim.

When his trial opened in late December, Mr Purnama denied blasphemy, saying his comments were aimed at politicians "incorrectly" using the Koran against him. If convicted, he faces a maximum five-year jail sentence.

Security is high in the capital, which has seen repeated angry protests against the governor, led by the hardline Islamic Defenders Front (FPI).

'Everyone cares about this election': By Rebecca Henschke, BBC News, Jakarta

It's a local election that feels like a presidential election, and voters here say stakes are high.

There were queues at the polling station near Governor Ahok's house, where Minarni voted. She said that she normally didn't bother to vote but this time it was different. "Everyone really cares about this election, it's such a decisive moment for the future," she said.

Governor Ahok's main rival, Anies Baswedan, has been accused of playing the race and religion card but his campaign staff tells me that if elected he will be a tolerant leader.

After voting, Mr Baswedan told reporters the decision was now in the hands of God. "We believe that everything is decided by Allah, and we will now pray. And we trust in God that we will give Jakarta a just and great leader."

At one polling station, we overheard people telling those queuing to make sure they "vote for a Muslim", before being warned by officials not to intimidate voters.

One of the voters here, Lip Purwantara, said many people had told him not to vote for a non-Muslim but it didn't change his decision.

"I am a devout Muslim but I don't care about the religion of our leaders. I am voting for someone who can make our city greener, cleaner and better place to live," he said.

Despite the trial, Mr Purnama remains popular with many of the capital's residents, for favouring greater access to education and healthcare, as well as efforts to improve the traffic-clogged city's public transport.

He has been credited with tackling corruption and turning a large red-light district into a park.

Image copyright Reuters Image caption "Ahok" still has widespread support despite his recent woes

But he has also been criticised for forced evictions of riverbank slums, to combat flooding and pollution. And he has offended officials with his brusque style, though YouTube videos of him berating them for doing a bad job were a hit with the public.

He has the backing of President Joko Widodo's party.

The blasphemy case has benefitted his main rivals, who are both Muslims.

Agus Harimurti Yudhoyono, 38, is a former army major and the son of former president Susilo Bambang Yudhoyono, while Anies Baswedan, 47, is a former education minister.

Official results will not be announced until later this month. But the election will likely go to a second round in April as no candidate is expected to secure the required 50% of the vote.