From independence in 1965 until 1994, Gambia had regular free and fair elections, although the same person - Dawda Jawara - won all of those elections, first parliamentary elections that indirectly made him prime minister, and then direct elections that made him president. In 1994, Jammeh overthrew Jawara and won multiparty presidential elections every five years from 1996-2011. Based on those four elections, no-one expected Jammeh to lose this time:
Some of those elections were close, but Jammeh repeatedly used state power to guarantee victory. For example, in advance of the 2011 election, the Commission for the Economic Community of West African States (ECOWAS) declined to send observers to Gambia, stating in a press release that “the preparations and political environment for the said election are adjudged by the Commission not to be conducive for the conduct of free, fair and transparent polls.” The Commission added, “The reports of [our] fact-finding mission and the Early Warning System paint a picture of intimidation, an unacceptable level of control of the electronic media by the party in power, the lack of neutrality of state and para-statal institutions, and an opposition and electorate cowed by repression and intimidation.”This year, Jammeh was taking similar steps to win the election. The opposition candidate who placed second in the previous four elections, Ousainou Darboe, was arrested in July. The night before the election, Gambian authorities turned off the internet. International phone calls and street protests were banned.
And yet Jammeh lost. Some possible reasons: Barrow, a real estate developer and opposition politician who emerged as the candidate for Darboe's party, united the opposition behind him by running as the candidate for a seven-party coalition rather than just his party. It may have helped that he was a fresh face.
It was equally surprising that Jammeh accepted the loss, given what appeared strong support from the security forces. Perhaps some members of the military were ready for a fresh face as well.
UPDATE: Economist December 10 story on the "shock victory". And of course Jammeh didn't stick with his acceptance of the loss.