The riots came after the General Election Commission announced President Joko Widodo had beaten his challenger former general Prabowo Subianto in the April 17 presidential poll.
Calm returned to the streets of central Jakarta on Thursday after a second night of clashes between security forces and protesters angry over the outcome of last month's election, which handed Indonesian President Joko Widodo a second term.
However, their numbers thinned as the night wore on and police spokesman Dedi Praseyto said the last remaining protesters had dispersed by 0000 GMT (7 am local time).
Roads that were quiet on Wednesday as office workers stayed away from the city centre were abuzz with rush-hour traffic, all but one of the city's MRT stations were open and government workers in orange overalls swept debris off the streets.
Jakarta Governor Anies Baswedan said six people were killed in the first night of rioting, which was concentrated in the sprawling textile market neighbourhood of Tanah Abang. State news agency Antara reported that three hospitals had treated more than 350 people for injuries.
The unrest followed an announcement by the General Election Commission confirming that Widodo had beaten his challenger, former general Prabowo Subianto, in the April 17 poll.
Widodo won more than 85 million of 154 million votes cast but Prabowo alleged "massive cheating and irregularities" and refused to concede defeat. The election supervisory agency has said there was no evidence of systematic cheating and independent observers have said the poll was free and fair.
A crowd of protesters swelled outside the supervisory agency's headquarters on Wednesday, some carrying wooden poles and some with toothpaste smeared around their eyes to mitigate the effects of tear gas.
Many left peacefully, but as night fell others hurled firecrackers and other objects at officers and set fires as they tried to breach barbed wire separating them from police. Police responded with tear gas, rubber bullets and water cannon.
Medics were seen treating dozens of protesters affected by tear gas and using oxygen to revive some who had passed out.
Many of the protesters appeared to have come from outside Jakarta and police found envelopes containing money on some of the people they searched, national police spokesman Muhamad Iqbal told a news conference on Wednesday.
"This is not a spontaneous incident, this is something by design. There are indications that the mobs are paid and bent on causing chaos," he said.
Probowo, in a video posted on his Twitter account before midnight on Wednesday, urged his supporters to leave peacefully.
"I beg you to return to your homes to rest, avoid any actions that would break the law," he said.
Prabowo's political party, Gerindra, complained that the authorities were trying to pin blame for the riots on him.
"We saw efforts to herd public opinion so that the peaceful protest would look like disturbing acts, with an end goal of discrediting Mr Prabowo," Gerindra said on Twitter.
Prabowo's camp has said it plans to contest the result of the election –– which gave Widodo a 55.5 percent share of votes against 44.5 percent for his challenger –– in the Constitutional Court on Thursday. Prabowo also launched an unsuccessful legal challenge after Widodo defeated him in the 2014 election.
Analysts say Widodo's double-digit margin of victory means the opposition does not have a strong case to claim rigging but he may be able to count on continued agitation over the election result by supporters.
Right-wing groups have been able to mobilise mass support in the past. They organised a series of massive protests from late 2016 against then-Jakarta governor Basuki Tjahaja Purnama, the first ethnic-Chinese Christian to hold the job, who was subsequently jailed for insulting the Koran.
The government put 40,000 police and soldiers on duty across Jakarta to maintain security this week and temporarily blocked some social media functions to prevent inflammatory hoaxes and fake news that could fan unrest.
Jakarta police tweeted on its official account a short video of topless men, some with heads shaven, squatting in two lines, with a caption that described them as "hundreds of rioters" who had been arrested.
Police displayed at a news conference suspects in orange jumpsuits as well as petrol bombs, makeshift arrows, sickles and cash in envelopes.
Police chief Tito Karnavian, showing reporters a sniper rifle with a silencer and two revolvers that were seized from people arrested days before the rioting broke out, said: "There is an effort to provoke, to create martyrs, blame the authorities and invoke public anger."