Defeated Indonesian presidential candidate Prabowo Subianto is set to lodge a challenge to the result of the 17 April election in the Constitutional Court on Friday after complaining that the vote was rigged.

President Joko Widodo won 55.5 per cent of votes in the poll to lead the world’s third biggest democracy, beating retired general Mr Prabowo, who got 44.5 per cent, the General Election Commission (KPU) said on Tuesday.

After the announcement, Mr Prabowo repeated earlier claims that there had been widespread cheating in favour of the incumbent and thousands of his supporters demonstrated in the capital this week to protest against the result.

Eight people were killed, including three teenagers, while 737 were hurt in two nights of rioting, Jakarta Governor Anies Baswedan said.

The election agency has said there was no evidence of systematic cheating and independent observers have said the poll was free and fair.

Delivering ballot boxes to Indonesia's hard to reach places Show all 10 1 /10 Delivering ballot boxes to Indonesia's hard to reach places Delivering ballot boxes to Indonesia's hard to reach places Workers transport ballot boxes to Bonto Matinggi village, South Sulawesi AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Army and police guards guide the delivery of ballot boxes in remote East Java AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Election officials deliver ballot boxes to a remote village in Southern Aceh AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes to Bandung in West Java amidst heavy flooding AP Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes to villages outside the city of Bogor EPA Delivering ballot boxes to Indonesia's hard to reach places Election officials load ballot boxes for delivery to a remote village in Southern Aceh AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes to remote villages in Papua province AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers deliver ballot boxes by boat to remote villages in Papua province AFP/Getty Delivering ballot boxes to Indonesia's hard to reach places Workers load ballot boxes onto a lorry in North Sumatra AP Delivering ballot boxes to Indonesia's hard to reach places Army and police guards guide the delivery of ballot boxes in remote East Java Reuters

“The process of submitting the dispute lawsuit and other legal efforts are steps to ensure that we can carry election results that are free and fair,” Mr Prabowo’s running mate, Sandiaga Uno, told reporters.

The last ranks of protesters dispersed early on Thursday, but opposition supporters are expected to gather again on Friday near the court, which is close to the presidential palace in the heart of the capital.

Police have arrested hundreds of people accused of taking part in the riots or provoking violence, two of whom were members of a militant group that had pledged support for Isis, national police spokesman Muhammad Iqbal said.

Police had also found envelopes containing money, suggesting instigators had paid some of the rioters, Mr Iqbal said, adding that tests showed some of the suspects had taken the stimulant methamphetamine.

The Constitutional Court must make a ruling on the challenge 14 days after it considers the plaintiff has provided sufficient documentation. The Election Commission should resolve the dispute by 15 June.

President Widodo has warned of tough action against those instigating riots, while Mr Prabowo has called for peaceful protests and restraint.

Mr Prabowo also lost the 2014 presidential election to President Widodo by a slimmer margin and had objected to that result, lodging a complaint with the Constitutional Court that was rejected.

The government has deployed 58,000 police and soldiers across Jakarta to maintain security and put temporary blocks on some social media to prevent unrest sparked by fake news.