The Gambia’s president of 22 years Yahya Jammeh will be replaced by a property developer, Adama Barrow, after losing the general election.
Mr Jammeh, who came to power in a coup in 1994, has agreed to accept defeat, 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 power transfer since independence in 1965.
Mr Njie said that Mr Barrow had won Thursday’s election by more than 50,000 votes. He runs a property company which he founded in 2006.
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 told reporters.
Mr Jammeh’s defeat has been greeted with astonishment in The Gambia, where most people expected him to win. He has served four terms as president but now this unpredictable and ruthless man is to be replaced by a property developer.
Mr Jammeh’s 22 years in power have brought repression and intolerance to this tiny seaside nation, popular for cheap holidays in the sun.
He has been tough on journalists, the opposition and gay people. He also said he could cure Aids and infertility.
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.
The economic challenges the country faces have forced many to make the perilous journey to Europe, with some drowning on the way, he said.