When President Yahya Jammeh accepted electoral defeat in the tiny west African nation of Gambia two weeks ago, voters and democracy advocates alike cheered. Jammeh, who once claimed a "billion-year" mandate and has been in power for 22 years, was finally vacating his throne.

But the celebrations were premature. A week later, Jammeh decided that the elections were in fact flawed and rejected the results. The reversal highlights one of the most enduring obstacles to democracy in Africa, where leaders often stay long past their welcome.

President Teodoro Obiang Nguema Mbasogo of Equatorial Guinea is Africa's longest serving leader after he seized power in 1979. José Eduardo dos Santos has been the president of Angola for about the same time. Robert Mugabe who has been ruling Zimbabwe since 1980 comes a close third — and the 92-year-old will likely be running in the 2018 elections.

There's reason for hope. Gambia's neighbor Senegal saw a peaceful transfer of power in 2012. Last year, Africa's most populous nation Nigeria held an election that ushered in a new president. Last week, Ghana voted for opposition leader Akufo-Addo, booting out the incumbent after just one term in office. Jammeh of Gambia should heed their examples. Not doing so risks the violence and chaos that has roiled nations where despots have clung to power.

See more from Opinion / Analysis here