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