Joko Widodo has been re-elected as Indonesia's president after last month's vote, beating former general Prabowo Subianto.
The result was released a day ahead of schedule in the early hours of Tuesday, amid fears of unrest.
Around 32,000 security personnel were deployed across the capital Jakarta, AFP news agency reports.
Mr Prabowo rejected the result and said he would pursue "legal avenues", but urged his supporters to stay calm.
Ahead of the final tally he had alleged "widespread cheating" and warned of potential street protests. In 2014 Mr Prabowo challenged an election defeat by Mr Widodo in Indonesia's constitutional court, but lost.
The latest vote followed a bitter campaign in which religion played a key role, but independent observers have said it was free and fair.
Mr Widodo won 55.5% of the vote to Mr Prabowo's 44.5%, the election commission said. More than 192 million people were eligible to vote in the 17 April poll, choosing 20,000 local and national lawmakers.
Azis Subekti, a witness from the retired general's campaign team, refused to sign the results.
"We won't give up in the face of this injustice, cheating, lies, and these actions against democracy," he said.
What's the situation on the ground?
Authorities have appealed for calm and increased security measures in a bid to manage tensions.
Security personnel have been stationed in front of the election commission's office, backed by razor wire and water cannon.
On Friday police said they had arrested dozens of suspected terrorists with links to Islamic State (IS), some of whom had allegedly planned to bomb political rallies when the vote result was released.
The same day, the US embassy issued a travel warning advising its citizens in Indonesia to avoid demonstrations and political gatherings.
What were the election issues?
The two rival election campaigns focused on the economy, infrastructure and corruption.
Religion was also a core issue. Though Indonesia has no official state religion and the right to practise other faiths is enshrined in the constitution, some 80% of the country is Muslim.
Conservative Muslim groups have grown increasingly vocal in recent years, and observers say the presidential candidates both sought to tout their Islamic credentials.
Mr Widodo, himself a religious moderate, picked powerful cleric Ma'ruf Amin as his running mate, while Mr Prabowo promised to protect Islamic leaders and increase funding for religious schools.
In 2016, Jakarta's Chinese-Christian governor Basuki Tjahaja Purnama - known as Ahok - was accused by hardliners of blasphemy against Islam. After mass rallies in the streets, he was imprisoned for two years.
Though 80% of the country is Muslim, Indonesia has no official state religion and the right to practise other faiths is enshrined in the constitution.
Who is the re-elected president?
Joko Widodo has been president since 2014 when he also beat Mr Prabowo in a hotly-contested vote.
The 57-year old comes from humble beginnings and has focused his campaigns very much around his image as a "man of the people".
He first came to international prominence by becoming governor of Jakarta in 2012.
Under his presidency, Indonesia's economy has grown steadily.
Yet he has disappointed some supporters by abandoning campaign promises to resolve human rights violations. He has also courted massive Chinese infrastructure investment, which some in the country view as controversial.
His political rival, Mr Prabowo, 67, is closely associated with Indonesia's traditional political elite.
He was previously married to the daughter of former dictator General Suharto, who ruled Indonesia with an iron fist for 30 years.
Mr Prabowo has been accused of complicity in human rights abuses committed under Gen Suharto, but has maintained his innocence.
Despite his background, during the campaign he sought to distance himself from the political class and railed against the "evil elites in Jakarta". He promised to review all Chinese investment projects in Indonesia.