AT A time when democracy across much of Africa has been in retreat, it seemed at first that tiny Gambia had done something to restore faith in it. In an election on December 1st, out went President Yahya Jammeh, an autocrat who had ruled for 22 years, and in came Adama Barrow, a former security guard at a high-street discount store in London. Now, though, just eight days after graciously conceding defeat, Mr Jammeh (pictured) has deprived 2016 of a cheerful ending by declaring that he will not step down after all.

In a speech broadcast on state television late on December 9th, Mr Jammeh claimed there had been “unacceptable errors” in the voting tallies, demanding not merely a recount but (illogically) a re-run of the entire election. Or that, at least, was what he said he wanted. To most onlookers, it seemed all but certain that he was making a brazen attempt to cling to power, an impression reinforced by him also banning street protests against his decision, and sending troops out on the streets.

Mr Jammeh was swiftly condemned both by the UN Security Council and the African Union, which is less willing than it used to be to tolerate leaders who refuse to accept voters’ verdicts. But harsh words may not be enough. Mr Jammeh is not due to hand over power anyway until January, meaning he is still in charge of the security forces. And while many rank-and-file soldiers were seen celebrating his defeat last week, the henchmen that make up his presidential entourage are probably the biggest, strongest gang in town should it come to a scrap.

Yet if, as it now seems, Mr Jammeh had no intention of giving up power all along, why did he wait until a week after the election to try to grab it back? Looking for rationality in Mr Jammeh’s mind is not easy. This, after all, is a leader who claimed to have invented a herbal cure for HIV, whose grasp of witchcraft was widely considered to be better than his grasp of statecraft.

But one theory among diplomats in Gambia is that he had become so confident of his own popularity that on this particular vote—his fifth since seizing power—he did not bother to rig it, allowing ballots to be counted on the spot rather than in central counting houses away from prying eyes. When that relatively fair and transparent vote caught him by surprise, it took several days for him to work out a plan of action, during which time he had little choice but to play the role of magnanimous loser.

Quite apart from his enthusiasm for power—he once declared he would rule for “a billion years if Allah decreed it”—Mr Jammeh also knows that if he steps down he will almost certainly face prosecution for past human-rights abuses, most of them against the very opposition politicians who have just won power.

A lot now depends on the dynamics within both the security forces and his own party. If those who fear they might end up in the dock with him prevail over those who think they can quietly walk away, they may stand behind him. International sanctions will almost surely follow, but given that Mr Jammeh has already left the Commonwealth, quit the International Criminal Court and told the UN to “go to hell” over past human-rights scandals, he is unlikely to worry much about Gambia being a pariah state.

A second interpretation of events is that by threatening trouble, Mr Jammeh is gambling that some other country may offer him refuge. One possible bolt-hole might be a nearby African nation. Another is Saudi Arabia, which already hosts the ousted Tunisian dictator, Zine el-Abidine Ben Ali, and also took in the late Idi Amin of Uganda.

For those who languished in Mr Jammeh’s torture cells, seeing their old foe in comfortable exile might be only marginally less palatable than having him stay in power. Yet many diplomats believe it could be for the best, if only in the short term, while Mr Barrow’s fragile, untested coalition gets the hang of the government. They are mindful of what happened with the Ivory Coast’s leader, Laurent Gbagbo, who, after disputed elections in 2010, was offered a study fellowship in America if he would go quietly. He refused, plunging his country into a civil war that cost 3,000 lives.

Nor, diplomats point out, would exile necessarily be forever. International pressure could be applied again to get Mr Jammeh extradited. That might involve an AU-convened court in another country, as happened with the Chadian despot, Hissène Habré, who was jailed for life this year after a trial in Senegal. That, admittedly was some 26 years after he was deposed, hardly the kind of time-frame that most Gambians would want. Right now, though, the choice may be between an eternity waiting for justice, or an eternity under Mr Jammeh.