jakarta - A massive demonstration by tens of thousands of Indonesian Muslims against jakarta 's governor turned ugly Friday as they burned police cars and officers were injured in angry clashes.

The violent scenes - just metres from the presidential palace and city hall - marred an otherwise peaceful rally against Governor Basuki Tjahaja Purnama, a Christian accused of blasphemy.

Three officers were injured as radical protesters hurled stones and bottles at police , who responded with tear gas, national police spokesman Boy Rafli Amar told AFP.

"I hope the injuries are not serious, they have been taken away from the scene," he said. "The latest situation is we're persuading the protesters to go home, and some have started to leave, especially after we fired tear gas. But some still refuse."

police had earlier declared the much-hyped demonstration against Purnama, in which 50,000 protesters gathered at the city's largest mosque before taking to the streets in a huge show of force, a largely peaceful affair.

Authorities took no chances in the lead up to the protest, deploying 18,000 officers and extra soldiers across jakarta amid fears that radical elements could infiltrate the march.

The demonstration appeared to be dying down by dusk as thousands began leaving the protest zone. But as night fell mobs of hardliners, draped in the white uniforms favoured by Indonesian extremist groups, ran amok and attacked police , who hit back with tear gas, water cannon and truncheons.

Gangs torched police vehicles in front of the presidential palace, an AFP correspondent at the scene reported.

The protest was triggered by accusations that Purnama, better known by his nickname Ahok, insulted Islam by criticising opponents who used Quranic references to attack him ahead of an election in February.

Purnama apologised for the remarks, but his opponents have built a groundswell of support calling for his arrest and incarceration under Indonesia's blasphemy laws.

The protesters have called for his death and promised Friday's turnout would eclipse a similar rally last month that drew 10,000 chanting demonstrators to the streets.

Some foreign embassies warned their citizens to steer clear of the demonstration.

Anger spread beyond the capital, with solidarity marches also held across Java and in cities as far away as Makassar in Indonesia's east.

President Joko Widodo met this week with religious and political leaders to issue a unified call against violence while police sought to ease tensions by holding prayer sessions and broadcasting calls for peace on social media.

Purnama is hugely popular in other quarters for his determination to clean up jakarta , an overcrowded, disorganised and polluted metropolis.

He became jakarta governor in November 2014, but was not elected to the post. He was deputy governor and automatically became governor after incumbent Widodo was elected Indonesian president.