Six people have died in rioting in the Indonesian capital, authorities said, as supporters of a losing presidential candidate burned vehicles and battled police, and the government announced restrictions on social media.

The clashes began on Tuesday night when supporters of former general Prabowo Subianto tried to force their way into the offices of the election supervisory agency and have continued unabated since then.

More than two dozen vehicles were burned as rioters took over neighbourhoods in central Jakarta, throwing rocks and petrol bombs at police who responded with tear gas, water cannons and rubber bullets.

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

Mr Subianto, a volatile ultra-nationalist politician, has refused to accept the official results of the April 17 election and instead declared himself the winner.

The Election Commission said President Joko Widodo, the first Indonesian president from outside the Jakarta elite, had won 55.5% of the vote, securing the moderate technocrat a second term.

Mr Subianto, an elite figure from a wealthy family connected to former dictator Suharto, also lost to Mr Widodo in 2014. He has made four unsuccessful bids for the presidency since Suharto was ousted in 1998.

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

Rudiantara, the communications and information technology minister, said features of social media including Facebook, Twitter and WhatsApp will be restricted temporarily to prevent the spread of hoaxes and inflammatory content.

He said messaging systems will still work for text and voice messages but photos and videos will be blocked.

National police chief Tito Karnavian said the people who died in the rioting were hit by gunshots or blunt devices. Authorities are still investigating the causes and are not ruling out the involvement of third parties acting as provocateurs.

“There are attempts to create martyrs, blaming security officials for building public anger,” he said.

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

The rioting in Jakarta was planned and not spontaneous, according to police. Officers found an ambulance filled with stones and some of the dozens of people arrested had envelopes of money, said national police spokesman Muhammad Iqbal.

The government had deployed 50,000 police and soldiers in Jakarta in anticipation of protests following the official election results. Many residents have left the city and parts of the centre are closed to traffic, with the election supervisory agency and the 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)

In the past week, authorities have arrested three pro-Subianto activists on suspicion of treason. 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’s 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 former special forces general and members of his campaign team had said they would mobilise “people power” during days of street protests. The former general has called on supporters to refrain from violence.

He 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.