It was the election result analysts predicted would never happen. And even if it did, everyone thought the mercurial president of the tiny West African nation of Gambia, who once said he would rule for a billion years, would cling to power.
Just last month, Yahya Jammeh, 51, declared that no mortal could take power from him, only god.
Instead, Jammeh, an authoritarian figure who ruled with fear after taking power in a coup 22 years ago, conceded defeat Friday night on state television.
Voters cast marbles in steel cans Thursday, the traditional voting method.
The vote sees West Africa emerging as a democratic stronghold in Africa with several peaceful democratic transfers of power in the region, including last year's momentous election in Nigeria, where the president, Goodluck Jonathan, conceded defeat to Muhammadu Buhari.
The difference between the 2016 Gambian election and previous votes was that Gambia's fractured opposition joined forces in a coalition behind a former businessman, Adama Barrow, who pledged to restore human rights and the rule of law. Barrow promised to release political prisoners and end disappearances and imprisonment without trial.
The electoral commission declared Barrow the victor with 45.5% of the vote against Jammeh's 36.7%. A minor third candidate, Mama Kandeh, got the remaining vote.
The election provides a model for opposition forces in other African countries, in many cases small splintered groups arrayed around personalities or ethnicity, who often lose power because of a failure to unite forces.
Jammeh seized power in a 1994 coup, but then was elected to his first five-year term in 1996. Had he won this week, it would have been his fifth term in office.
"Being called a dictator doesn't bother me at all because I am a dictator of development and progress," Jammeh said last month.
The Gambia is a sliver of a nation situated on the Gambia River and its delta, within the borders of Senegal. The former British colony of 1.8 million people depends on agriculture, remittances and tourism for survival. With high youth unemployment and 58% of the population under 25, thousands of young people leave the country annually, many of them making hazardous journeys across the Mediterranean Sea to try to get to Europe.
Jammeh's leadership style was at times eccentric. He always wore white and decreed that he should be known as "His Excellency Sheikh Professor Alhaji Doctor." In 2007 he announced he could cure AIDS and asthma and began holding bizarre herbal treatment sessions with patients.
In 2009, after his aunt died, Jammeh blamed witchcraft and dispatched security forces to round up about 1,000 "witches" and "sorcerers" in one village. Those detained were forced to drink a herbal concoction which made them hallucinate, and many were severely beaten, according to Amnesty International.
In 2012 he announced he would have all 47 prisoners on death row executed by firing squad. Several days later, nine prisoners were shot, but he didn't carry through his threat to execute the other 38.
In December 2014, when Jammeh was out of the country, a group of gunmen launched a coup attempt but were swiftly overcome by Jammeh's presidential guard. Four U.S. citizens of Gambian origin who plotted the coup were tried in the United States for contravening the Neutrality Act, which makes it illegal to engage in military action against a country friendly to the U.S. They were convicted and sentenced to up to a year and a day in jail.
An earlier coup attempt was thwarted in 2006.
On Wednesday Jammeh had warned opposition supporters that protests would be banned after the election result came in. Internet access, cut off during voting, was restored Friday, and Barrow supporters celebrated in the streets.
Jammeh's acceptance of this week's balloting consolidates democracy in West Africa, where peaceful power transitions have taken place in recent years in Nigeria, Senegal and Ghana; in Burkina Faso people power averted both a military coup and the attempts of a longtime president to cling to power.
In some other parts of the continent, however, democracy has not been doing so well. Somalia's auditor general said last month that parliamentary elections were not credible because of fraud and vote-buying, and the country's presidential vote, a crucial step to stabilize the country, was postponed this week.
Numerous presidents in Africa have delayed elections, ignored presidential term limits, shut down independent media or repressed opposition candidates in recent times.
Meanwhile, some African presidents have ruled for decades, including Zimbabwe's Robert Mugabe, Cameroon's Paul Biya and Uganda's Yoweri Museveni.