Yahya Jammeh, The Gambia’s authoritarian president of 22 years, has suffered a surprise defeat in the country’s general election.
He will be replaced by a property developer, Adama Barrow, who won more than 45% of the vote.
Jammeh, who came to power in a coup in 1994, has conceded, said electoral commission chief Alieu Momar Njie.
Before announcing the final result, Mr Njie appealed for calm as the country entered unchartered waters.
The Gambia has not had a smooth transfer of power since independence in 1965.
Barrow won 263,515 votes (45.5%) in Thursday’s election, while President Jammeh took 212,099 (36.7%), according to the electoral commission.
Barrow, who runs his own property company, reportedly used to work as a security guard at an Argos department store on London’s Holloway Road.
On the electoral campaign, he promised to revive the country’s economy, which has forced thousands of Gambians to make the perilous journey to Europe.
President Jammeh’s defeat comes as a huge surprise. Despite a surge of support for an opposition broadly united behind one candidate, most people expected the status quo to prevail.
Hopes weren’t high for a peaceful transfer of power, with a crackdown on opposition leaders months before the polls, the banning of international observers or post-election demonstrations, and then the switching off of the internet.
But in a place where glass beads are used in place of ballot papers, it seems that the marbles have spoken.
The unseating of an incumbent president is not the usual way politics goes in this part of the world – but it’s becoming popular in West Africa at least, with Muhammadu Buhari unseating Goodluck Jonathan in Nigeria just last year.
Former businessman Adama Barrow now has his chance to tackle the poverty and unemployment which drives so many young Gambians to join the Mediterranean migrant trail every year.
A devout Muslim, Mr Jammeh, 51, once said he would rule for “one billion years” if “Allah willed it”.
“It’s really unique that someone who has been ruling this country for so long has accepted defeat,” Mr Njie, the electoral commission chief, told reporters.
During the campaign, the country’s mostly young population seemed to be yearning for change, said the BBC’s Umaru Fofana in the capital, Banjul.
Human rights groups have accused Mr Jammeh, who has in the past claimed he can cure Aids and infertility, of repression and abuses.
Several previous opposition leaders are in jail after taking part in a rare protest in April.
Observers from the European Union (EU) and the West African regional bloc Economc Community of West African States (ECOWAS) did not attend the vote.