JAKARTA: A massive demonstration by tens of thousands of Indonesian Muslims against Jakarta’s governor turned ugly on Friday as hardliners burned police cars and clashed with officers, who responded with tear gas and water cannon.

The ugly scenes — just metres from the presidential palace — marred an otherwise peaceful rally against governor Basuki Tjahaja Purnama, a Christian accused of insulting Islam.

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.

But as night fell thousands of radicals turned violent, setting police cars ablaze and attacking officers who hit back with tear gas, water cannon and truncheons.

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 around city hall, the presidential palace and national monument.

But by nightfall riot police were put to the test as mobs of hardliners, draped in the white militant uniforms favoured by Indonesian extremist groups, ran amok, hurling bottles, stones and lighting fires as officers used shields for cover.

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 tough blasphemy laws.

“It’s no wonder people arise. Why when it comes to Ahok is the law not upheld?” deputy house speaker Fahri Hamzah, a prominent politician from an Islamic political party, told demonstrators earlier on Friday.

Anger at Purnama, Jakarta’s second Christian governor and the first from the country’s ethnic Chinese community, spread beyond the capital, with solidarity marches also held across Java and in cities as far away as Makassar in Indonesia’s east.

The military warned it was ready to back police if things turned ugly, with helicopters flying low over the city and extra soldiers stationed at key government buildings reinforced with razor wire and armoured vehicles.