Sri Lanka's former wartime defence chief Gotabaya Rajapaksa has won a presidential election that has split the country along ethnic lines.
Official results showed Mr Rajapaksa, 70, took 52.25% of the vote. His rival Sajith Premadasa had already conceded.
Mr Rajapaksa was the clear victor in Sinhalese majority areas while Mr Premadasa scored better in the Tamil-dominated north.
The election is Sri Lanka's first since the deadly Easter Sunday attacks.
Militants linked to the Islamic State group targeted churches and high-end hotels across the island in April, killing more than 250 people. As a result, national security was seen as a dominant issue ahead of the vote.
Mr Rajapaksa, who has positioned himself as a strong figure who can assure Sri Lankans' security, is a highly controversial figure among the country's more than two million Tamils.
He and his brother Mahinda Rajapaksa, the former president, spearheaded the defeat of separatist Tamil Tiger rebels in 2009, ending a decades-long war in which at least 100,000 people died.
Several journalists who were critics of the government when the Rajapaksas led Sri Lanka from 2005-2015 were abducted, tortured and killed. Thousands of people, particularly Tamils, vanished in what have been described as enforced disappearances.
Votes appeared to be starkly divided between the Sinhala Buddhist majority and minority Tamil, Hindu and Muslim groups, raising fears about the future of reconciliation in a country that remains heavily polarised along ethnic and religious lines a decade after the end of the bitter war.
After his election win, Mr Rajapaksa made a call for unity in the country.
"It is my duty to serve all Sri Lankans without racial or religious discrimination," he said. "I promise to discharge my duties in a fair manner."
As we usher in a new journey for Sri Lanka, we must remember that all Sri Lankans are part of this journey. Let us rejoice peacefully, with dignity and discipline in the same manner in which we campaigned. pic.twitter.com/tXqLrdH3Qv— Gotabaya Rajapaksa (@GotabayaR) November 17, 2019
Human rights groups expressed concern about accountability for wartime abuses - which were committed by both sides - given the election of a man so closely associated with the end of the conflict.
Mr Premadasa, who took 42% of the vote, publicly conceded when partial results showed Mr Rajapaksa was certain to emerge the winner.
"It is my privilege to honour the decision of the people and congratulate Mr Gotabaya Rajapaksa on his election as the seventh president of Sri Lanka," Mr Premadasa said.
Turnout was 83.7%, the election commission said. Mr Rajapaksa is due to be sworn in at a ceremony on Monday.
Unity and reconciliation will not be easy
By Jill McGivering, BBC News, Sri Lanka
Gotabaya Rajapaksa commands passionate support among many in the Buddhist Sinhalese majority in Sri Lanka.
He and Mahinda, who was president here for 10 years, are credited with bringing an end to the country's long civil war.
"I think it's a turning point in the history of Sri Lanka," said a Rajapaksa supporter, lawyer Janaka Arunashantha. "With economy and national security, I think the country will improve in every way in the next five years. We're very hopeful with him."
Sri Lanka is still in shock, seven months after the bomb attacks by a cell of Islamist militants which devastated the island's economy, blew apart the island's fragile communal relations and was the final blow to public confidence in a government already tarnished by infighting.
But the news will be greeted with quiet dismay by many in the minority communities who voted overwhelmingly not for Mr Rajapaksa but his rival, Sajith Premadasa. They see him as a more liberal, inclusive choice.
Unifying the different communities - and pursuing post-war reconciliation - will be a daunting task.
The Easter Sunday attacks cast a long shadow over the election.
The government was forced to admit it had suffered a "major intelligence lapse" after failing to adequately share information from Indian intelligence officials about a potential attack.
But since the attacks, Muslims - who make up nearly 10% of Sri Lanka's 22 million people - say they have faced a more overt campaign of hate against them, fuelled by hardline Buddhist groups.
Muslim shop owners say they have been boycotted and there have been outbreaks of mob violence.
More about Sri Lanka and the Easter Sunday bombings
A total of 35 candidates stood in the presidential election, the third since the end of the civil war.
The country's incumbent president, Maithripala Sirisena, was not on the ballot. He decided against running after coming under criticism following the Easter Sunday bombings.
Ruling party candidate Mr Premadasa focused on social issues as well as security - campaigning on a promise to eradicate poverty and improve housing.
He is the son of a president who was assassinated by Tamil Tiger rebels in 1993 and is the current housing minister.
The previous Rajapaksa era was marked by close ties between Sri Lanka and China, with the latter investing billions in infrastructure and development on the island.
However the island's ballooning debt to Beijing worried many Sri Lankans. Regional powers including India expressed concern about the extent of Chinese influence in the country.
Gotabaya Rajapaksa said he planned to "restore relations" with China, if he won the election. Mr Premadasa, meanwhile, was seen as leaning more towards India and the US.