INDONESIA’S president urged protesters rioting in Jakarta today to return to their homes, lamenting the “chaos” in the capital as gangs of hard line Muslims torched police cars and attacked officers.

The violence — just metres from the presidential palace and city hall — marred an otherwise peacefully rally yesterday in which 50,000 people marched against Jakarta governor Basuki Tjahaja Purnama, a Christian accused of insulting Islam.

President Joko “Jokowi” Widodo cancelled a visit to Australia after the rally.

The Foreign Affairs Ministry says Jokowi’s trip scheduled from Sunday to Tuesday will be rescheduled because “current development has required the president to stay in Indonesia.”

The statement added that Widodo had called Australia’s Prime Minister Malcolm Turnbull to inform him that the trip, scheduled for 6-8 November, would be delayed.

“I said we were very sorry we would not be able to welcome him to Australia tomorrow but entirely understood the need for him to remain in Indonesia at this time,” Mr Turnbull said in his own statement. “President Widodo thanked me for Australia’s understanding and noted his desire to conduct the visit as soon as mutually convenient times can be identified.”

The rally turned ugly as night fell and thousands of hardliners clashed with police, setting vehicles ablaze and hurling bottles and rocks at officers, injuring several. Police responded with tear gas, water cannon and truncheons but it took hours to quell the violence, which later spilt over into a poor neighbourhood in Jakarta’s north.

An elderly man died but his cause of death was not yet known, Jakarta police spokesman Awi Setiyono told AFP.

In a brief statement just after midnight, President Joko Widodo — flanked by senior officials including Indonesia’s military chief, security minister and national police chief — regretted the peaceful march descending into violence.

“People should have been dispersed but it ended up in chaos,” he told reporters at the palace.

“I ask the protesters to go home, and let law enforcement do their job in a fair way.”

The protest was triggered by accusations that Purnama, better known by his nickname Ahok, insulted Islam by criticising opponents who used Koranic 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.

Hardliners have called for his death and promised yesterday’s turnout in Jakarta would eclipse a similar rally last month that drew 10,000 chanting demonstrators to the streets.

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

Authorities took no chances in the lead up to the much-hyped Jakarta rally, deploying 18,000 officers and extra soldiers across the capital amid fears that radical elements could infiltrate the march.

The demonstration appeared to be dying down by dusk, but the situation turned hostile by nightfall as hardliners and riot police engaged in skirmishes.

By late yesterday the unrest in the city centre had largely been quelled but flared up in another area. Footage aired on Indonesian broadcaster TVOne showed what appeared to be looting at a convenience store in the same neighbourhood.

Widodo — who met this week with religious and political leaders to issue a unified call for calm — blamed “political actors” for fanning the violence, without elaborating.

He reassured protesters that legal proceedings into Purnama’s alleged transgressions would be concluded “quickly and transparently”.

Indonesia is home to the world’s biggest Muslim population, where a vast majority practise a moderate form of Islam.