DEPENDING on whom one speaks to, it was either an act of war or a map-reading error. When troops from neighbouring Senegal massed on the Gambian border this week—poised to force out Gambia’s dictator, Yahya Jammeh—reports emerged on Thursday night that they had already crossed the frontier. In fact, according to diplomats, they had merely misprogrammed their GPS navigator, and had strayed over the undulating, unmarked border by mistake.

The world’s first “invasion by Sat Nav error”? Or just a deliberate “mistake” to put the wind up Mr Jammeh? Nobody really knows. Although West Africa’s regional power bloc, the Economic Community of West African States (ECOWAS), may not be as slick as the Pentagon when it comes to military manoeuvres, its calm stewardship of this week’s crisis in Gambia has won it many admirers.

When Mr Jammeh reneged on his pledge to step down after losing elections in December to Adama Barrow, it seemed the tiny west African nation was about to go back to a time when leaders ignored election results with little fear of consequences. These days, though, the region prides itself as being one of the most democratic in Africa, and anyone who blatantly ignores a ballot can expect brickbats.

Hence it was that late on Friday night, after a week in which Gambia looked set to become a war zone, a delegation of ECOWAS leaders at last got Mr Jammeh to step down at the last minute. True, it was diplomacy at gunpoint, with the Gambian strongman having been warned that the Senegalese troops would roll in within hours if he did not relent. But a few hours later, around 3am on Saturday, Mr Jammeh gave a brief six-minute speech on Gambian television confirming that he would go. Thus ended more than two decades of autocratic rule started when the former army captain came to power in a coup in 1994.

Quite what led to the breakthrough is not clear as of yet. Previous ECOWAS delegations had left empty-handed, with Mr Jammeh proving deaf to stern finger-wagging administered by both Nigeria’s Muhammadu Buhari—himself a former military strongman—and Liberia’s Ellen Johnson Sirleaf. Indeed, after Mrs Johnson Sirleaf made her impatience clear at Mr Jammeh’s habit of ringing her up live on Gambian television to explain his latest negotiation positions, it was left to two new faces, Guinea’s Alpha Conde and Mauritania’s Mohamed Ould Abdel Aziz, to make the final push.

In his departure speech, Mr Jammeh said he was glad that “not a drop of blood” had been spilt. “I believe in...the capacity of Africans to resolve among themselves all the challenges on the way towards democracy.” That may smack of hypocrisy to some, of course, but it seems that part of the deal was to allow him to exit in dignified fashion. If the “Old Man”, as he is known to Gambians, wanted one last bit of grandstanding, then so be it.

The precise terms of Mr Jammeh’s departure are expected to be revealed later on Saturday. But first and foremost, he is expected to leave the country for good within the next day or two. A nearby African nation is expected to offer him refuge. Despite the breakthrough, the streets the Gambian capital, Banjul, remained quiet on Saturday, with Gambians putting the celebrations on hold until Mr Jammeh has flown out. They remember that he made a previous pledge to step down right after losing power in December’s elections, only to abruptly change his mind.

During the subsequent negotiations, several other countries, including Nigeria, Mauritania, Morocco, Sudan and Saudi Arabia, all offered him asylum. Officially, this is purely out of concern to ensure a peaceful transition of power, although some cynical diplomats did wonder whether the likes of Sudan may also be interested in the $3bn that His Excellency is said to have salted away during his 22 years in office. (Certainly, they put in a generous offer, extending the invitation not just to Mr Jammeh but also several hundred members of his entourage; Saudi Arabia’s offer, by contrast, was to take in just Mr Jammeh and nine of his closest chums.)

As of Saturday morning most diplomats were betting that he would head to Morocco. They point out that as it has not ratified the Rome Statute that established the International Criminal Court, Mr Jammeh may feel that he stands less of a chance of being extradited to face justice for his abuses of human rights. He may well be aware of the fate of the Liberian warlord, Charles Taylor, who was given refuge in Nigeria in 2003 only to be handed over to a court in The Hague in 2006. It sentenced him to 50 years in a British jail.

True, much as human-rights groups would like to Mr Jammeh in a dock, he is not in Mr Taylor’s league in terms of thuggery. He is blamed for hundreds or perhaps thousands of deaths, not hundreds of thousands, and if justice were to pursue him, it would probably be in the form of a specially convened regional prosecution chamber rather than the ICC, which focuses on rather bigger fish. But it could still take a decade or more to prepare a case, and by the time prosecutors were ready for him, Gambia might already have moved on to the point where its people preferred to forget his odious rule. In his departure speech on Saturday morning, Mr Jammeh loftily said he would submit “only to the judgement of Allah, whose judgment is above and beyond man”. That may, in the end, turn out to be true—but if it is the price for getting him to quit, many Gambians may deem it worthwhile.