Yahya Jammeh, The Gambia's authoritarian president of 22 years, has suffered a surprise defeat in the country's presidential elections.
He will be replaced by property developer Adama Barrow, who won more than 45% of the vote. After his win, Mr Barrow hailed a "new Gambia".
Mr Jammeh, who came to power in a coup in 1994, has not yet spoken publicly.
The West African state has not had a smooth transfer of power since independence from Britain in 1965.
Electoral commission chief Alieu Momar Njie appealed for calm as the country entered uncharted waters.
"I am very, very, very happy. I'm excited that we won this election and from now hope starts," Mr Barrow told the BBC's Umaru Fofana, adding that he was disappointed not to have won by a larger margin.
Mr Barrow won 263,515 votes (45.5%) in Thursday's election, while President Jammeh took 212,099 (36.7%), according to the electoral commission. A third party candidate, Mama Kandeh, won 102,969 (17.8%).
Who is Adama Barrow?
Born in 1965 in a small village near the eastern market town of Basse, Mr Barrow moved to London in the 2000s where he reportedly used to work as a security guard at an Argos catalogue store, while studying for real estate qualifications.
He returned to The Gambia in 2006 to set up his own property company, which he still runs today.
The 51-year-old won the presidential nomination in 2016 to lead an opposition coalition of seven parties - the largest alliance of its kind since independence, according to the AFP news agency.
On the electoral campaign, Mr Barrow - who has never held public office - promised to revive the country's economy, which has forced thousands of Gambians to make the perilous journey to Europe.
He has criticised the lack of a two-term limit on the presidency and says he would introduce a three-year transitional government made up from members of the opposition coalition.
How has the current president reacted?
The president has yet to give a public statement on the result, but he has spoken to his successor on the phone, according to the president-elect.
Mr Barrow told the BBC that President Jammeh had accepted his defeat and congratulated him.
President Jammeh also instructed his successor to arrange a time to meet and organise the transition process.
Mr Jammeh, a devout Muslim, had 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," the electoral commission chief, Alieu Momar Njie, said on Friday.
Why is it such a shock? By Alastair Leithead, BBC Africa correspondent
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.
What was it like living under President Jammeh?
Mr Jammeh seized power in a bloodless coup 22 years ago and has ruled the country with an iron fist ever since.
Human rights groups have accused Mr Jammeh, who has in the past claimed he can cure Aids and infertility, of repression and abuses of the media, the opposition and gay people.
In 2014, he called homosexuals "vermin" and said the government would deal with them as it would malaria-carrying mosquitoes.
Several previous opposition leaders were imprisoned after taking part in a rare protest in April.
Mr Barrow has previously described him a "soulless dictator" and promised to undo some of Mr Jammeh's more controversial moves, including reversing decisions to remove The Gambia from the Commonwealth and the International Criminal Court (ICC).
Was the election fair?
Celebrations erupted in the capital, Banjul, with Gambians shouting: "We are free. We won't be slaves of anyone."
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.
On voting day the internet and international phone calls were banned across the country.
Observers from the European Union (EU) and the West African regional bloc Ecowas did not attend the vote.
Gambian officials opposed the presence of Western observers, but the EU said before the vote it was staying away out of concern about the fairness of the voting process.
The African Union did despatch a handful of observers to supervise the vote, however.
Where is The Gambia?
The Gambia is the smallest country on mainland Africa, with a population of fewer than two million.
It is surrounded on three sides by Senegal and has a short Atlantic coastline popular with European tourists.
Tourism has become The Gambia's fastest growing sector of the economy, and it is known to travellers as "the smiling coast of West Africa".
Last year, President Jammeh declared the country an Islamic Republic in what he called a break from the country's colonial past.