Media playback is unsupported on your device Media caption Karishma Vaswani reports on Indonesia's controversial election result

Jakarta Governor Joko Widodo has been declared the winner of Indonesia's hotly contested presidential election.

The election commission said Mr Widodo - widely known as Jokowi - won 53.15% of the vote with his rival, ex-general Prabowo Subianto, on 46.85%.

Earlier, Mr Subianto alleged widespread electoral fraud and vowed to challenge the result.

Mr Widodo has promised a decisive break with Indonesia's authoritarian past and better social welfare for the poor.

Joko Widodo: Key facts

Born in 1961 in city of Solo, the son of a wood-seller

Began political career with the PDI-P party when he was elected mayor of Solo in 2005

Elected for second term in 2010 with more than 90% of the vote

Elected governor of Jakarta in 2012

Backer of technology who promises to implement "e-governance" to help cut bureaucratic corruption

Who is Joko Widodo?

What does Jokowi win mean for Indonesia?

Before the official results were confirmed, the chairperson of Mr Widodo's PDI-P party, Megawati Sukarnoputri, claimed victory on behalf of the candidate and his running-mate Jusuf Kalla.

"I want to declare that we, the party that supports and puts forward Joko Widodo and Jusuf Kalla, has won," she told reporters on Tuesday evening.

Indonesia's politics has traditionally been dominated by establishment figures from the political elite and military.

A former furniture-maker who grew up in a small village, Mr Jokowi is seen as a clean politician in touch with the masses. The Jakarta governor has proved to be particularly popular with urban and rural youth.

His rival Mr Subianto is a former general closely associated with the traditional elite. He had the backing of media tycoons.

A former son-in-law of Indonesia's ex-leader Suharto, Mr Subianto has faced multiple questions over alleged human rights abuses.

Image copyright AP Image caption Joko Widodo, right, and running-mate Jusuf Kalla celebrated as the results came in

Image copyright AFP Image caption Mr Subianto held a live televised press conference on Tuesday to declare his withdrawal

Image copyright Getty Images Image caption There has been a tight security presence at the election commission building in Jakarta amid fears of violence

Image copyright AFP Image caption Supporters of Mr Widodo shaved their heads to celebrate his victory in Jakarta

Jubilant supporters took to Twitter with congratulatory messages for Mr Widodo, using the hashtag #presidenbaru (New President).

Meanwhile about 100 supporters of Mr Subianto held a peaceful protest about 300m from the election commission building in Jakarta, declaring Mr Subianto the real president, the Associated Press reports.

Mr Subianto said earlier on Tuesday that his camp would not resort to violence as it challenges the results.

Security was tight for the announcement, with more than 250,000 police officers on duty across the nation, amid fears that supporters from both camps would clash.

About 130 million votes were cast on 9 July following an intense election campaign.

It was followed by a controversial vote-counting period in which both candidates raised concerns about voting irregularities.

But Mr Widodo's winning margin of 6% win is seen as decisive by analysts.

They say that even if Mr Subianto's claim of electoral fraud in certain areas proved to be true, this would be unlikely to change the overall results.

Mr Subianto has three days to file an appeal with Indonesia's constitutional court. The court has till 22 August to make a ruling on the results.