Gambian leader Yahya Jammeh, who once vowed to rule the tiny West African nation for "a billion years", said he had accepted his shock election defeat on Friday, 22 years after seizing power in a coup.
Voting on Thursday against Jammeh was a rare show of defiance against a leader who has ruled by decree and who rights groups say crushes dissent by imprisoning and torturing opponents.
In an address broadcast by Gambian state-owned radio on Thursday evening, Jammeh said he would not contest the poll results showing opposition candidate Adama Barrow had won, which had been announced earlier in the day.
"If (Barrow) wants to work with us also, I have no problem with that. I will help him work towards the transition," Jammeh said, before later saying that he planned to move to his farm after leaving office following a handover in January.
Celebrations erupted in the streets of Banjul, a normally sleepy seaside capital whose white beaches lined with palm trees are a draw for European tourists, when the results were announced.
Gambians shouted: "We are free. We won't be slaves of anyone." Some waved the Gambian flag and opposition party signs.
Official results from the electoral commission head gave Barrow, a real estate developer who once worked as a security guard at retailer Argos in London, 45.5 percent of the vote against Jammeh's 36.7 percent.
A peaceful handover of power in Gambia would be a welcome surprise for African democracy at a time when many of the continent's leaders have been rigging polls, fiddling with constitutions to extend their terms in office and cracking down on peaceful protest.
"African heads of state if they are defeated should take the example of Jammeh by leaving office honorably," said teacher Lamin Joof, celebrating in Banjul.
But his concession is unlikely to have a ripple effect across Africa since Gambia, a sliver of land along the banks of a river on its west coast with few natural resources and little trade or diplomatic presence, has always been an outlier.
Jammeh only this week said that his "presidency and power are in the hands of Allah and only Allah can take it from me".
"I never in my dreams believed he would concede. It almost feels to good to be true," said Ramzia Diab, an opposition member who fled to Senegal after getting death threats.
Jammeh's eccentricities have often made headlines. He once said he had invented a herbal cure for AIDS that only works on Thursdays. Once every year he also invited a few hundred women to the grounds of State House, where he personally administered another herbal cure he had concocted for infertility.
He arrested hundreds on suspicion of being witches or wizards and threatened to decapitate gay people.
Jammeh's supporters deny abuses and he has often criticized Western powers for meddling in African affairs.
The vote was marked by a blackout of the internet and international calls. Land borders were sealed. European Union observers were barred, though some African Union observers came.
The tourist flights that bring Gambia's main source of foreign exchange continued uninterrupted.
"Our resort teams in Gambia tell us that the situation is normal and that customers continue to enjoy their holidays," a spokesman for Thomas Cook, which organizes regular scheduled flights, said by email. He said the travel agent had 6,500 customers flying from Britain before end of the year.
Barrow somehow managed to unite and galvanize Gambia's opposition for the first time since Jammeh took power in the country of 1.8 million people.
He has promised to revive the economy, one of the region's poorest performers that pushes thousands of Gambians to flee to Europe in search of a better life.
Barrow has also pledged to end human rights abuses and to step down after three years as a boost to democracy.
It is unclear whether Jammeh, if he steps down, will insist on some kind of immunity for alleged abuses under his rule.
Gambia withdrew from the International Criminal Court last month, branding it the "Infamous Caucasian Court".
Karamba Touray, a spokesman for Barrow's UPD, said he would "stop plans to leave the ICC and ask to rejoin the Commonwealth immediately". He also said he would annul Jammeh's declaration of Gambia as an Islamic republic in December last year.
"He wants Gambia to remain a secular state and respect the rights of all the people," Touray said of a country that is predominantly Muslim but has a small Christian minority.
Small protests in Banjul in April led to dozens of arrests, including that of the leader of the main UDP opposition party, Ousainu Darboe. Two UDP members later died in custody.
"I want him to face justice, they have to make sure he faces the full wrath of the law," the opposition's Diab said. "People have died, many of us don't know where our family members are."