Supporters of an unsuccessful presidential candidate have clashed with security forces in the Indonesian capital, burning vehicles and throwing rocks at police, who responded with tear gas and rubber bullets.

The protesters tried to force their way into the central offices of the election supervisory agency late on Tuesday and clashes have continued since then.

Riot police launch tear gas
Riot police launch tear gas (AP)

National Police spokesman Muhammad Iqbal said the majority of protesters had come from outside Jakarta and nearly 60 people had been arrested.

Police said based on reports from hospitals that six people have died. Police chief Tito Karnavian told a news conference that authorities are still investigating the causes of death and are not ruling out the involvement of third parties acting as provocateurs.

He said the information police obtained showed victims were hit by gunshots or blunt devices.

Protesters run during a clash with police
Protesters run during a clash with police (Achmad Ibrahim/AP)

White-robed men blocked streets in one central Jakarta neighbourhood and in another, rioters fought running battles with police, throwing rocks and setting fires.

During the night, vehicles and a paramilitary police dormitory were set on fire as police using tear gas, rubber bullets and water cannons battled protesters who threw petrol bombs and burning projectiles.

The Election Commission on Tuesday said President Joko Widodo had won a second term with 55.5% of the vote in the April 17 election.

Joko Widodo meets supporters
Joko Widodo meets supporters (Dita Alangkara/AP)

Losing candidate Prabowo Subianto, an ultra-nationalist former special forces general, has refused to accept the result and declared himself the winner.

His campaign plans to challenge the election in the Constitutional Court. They allege massive fraud in the world’s third-largest democracy but have provided no credible evidence.

The government had deployed 50,000 police and soldiers in Jakarta in anticipation of protests, said police spokesman Argo Yuwono. Many residents have left the city and parts of the centre are closed to traffic with the election supervisory agency and Election Commission barricaded with razor wire.

Riot police outside the Election Supervision Board in Jakarta
Riot police outside the Election Supervision Board in Jakarta (Dita Alangkara/AP)

Indonesia’s top security minister said authorities will block access to social media in certain areas amid the protests.

Wiranto, who uses a single name, did not specify which areas would be subject to the restrictions.

Police have said the rioting was planned rather than a spontaneous outburst.

In the past week, authorities have arrested three pro-Subianto activists on suspicion of treason, said national police spokesman Dedi Prasety.

They included Sunarko, a retired general and former commander of Indonesia’s special forces who uses a single name. Police allege there was a plot to seize crucial government buildings in Jakarta.

Mr Subianto and members of his campaign team had said they would mobilise “people power” during days of street protests. The former general called on supporters to refrain from violence.

Mr Subianto, who also lost to Widodo in 2014, ran a fear-based campaign, emphasising what he sees as Indonesia’s weakness and the risk of exploitation by foreign powers or disintegration.

He aligned himself with hardline Muslim groups and won massive majorities in conservative provinces such as Aceh, which follows Shariah law, but was defeated by Mr Widodo in the president’s populous East Java and Central Java strongholds.

Mr Widodo’s campaign highlighted his progress in poverty reduction and improving Indonesia’s inadequate infrastructure with new ports, toll roads, airports and mass rapid transit.