BY THE end of this month an array of Western and African governments and regional bodies is supposed, according to a resolution passed unanimously last month in the UN Security Council, to have drawn up a detailed military plan to save the northern chunk of Mali from a clutch of Islamist rebel groups with ties to al-Qaeda. At the same time, tentative negotiations are already afoot to prise away one of the rebel outfits from its alliance with al-Qaeda. Even if that can be achieved, a full-blown counter-insurgency campaign is still likely, though it will probably not start in earnest for several months, despite the French defence minster’s initial rash assertion that it must begin within weeks.

The basic UN plan is for African leadership and manpower to combine with Western muscle and know-how to swat the rebels. It has been mooted that a force of 3,000-plus soldiers from Mali’s lousy and demoralised army plus another 3,000 or so from the other 14 countries in the Economic Community of West African States (ECOWAS), the regional club that is expected to lead the fray, will be backed by a contingent of a few hundred Western specialists, mainly from France and the United States, to provide intelligence, logistics, aerial firepower and surveillance (including drones), and perhaps small contingents of special forces. ECOWAS is ill-equipped to beat the jihadists on its own. The UN may need to beg for troops from elsewhere. Few expect an assault to begin before next year, despite the UN’s demands for urgency.

No one is confident of the outcome. The three main towns now in the hands of the Islamists—Gao, Kidal and Timbuktu—will probably be recaptured in due course. But whether the rebels can be completely expunged from the Sahara desert’s vast and rugged swathe of northern Mali is much less certain. It is not even clear that Mali’s own government will hold together. The international enterprise being cheered on by the UN is fraught with danger. Yet all the leading governments in America, Europe and Africa agree that drastic measures must be taken as soon as sensibly possible.

With France, Mali’s former colonial power, in the vanguard, the UN has been prodded into action by two main factors. First, the plight of Malians in the north of the country has worsened, as the Islamists impose a ruthless version of sharia law, including stoning for adultery, amputation of hands for theft, a ban on football, television and music, and the desecration of revered shrines now deemed idolatrous.

Second, it is feared that if the Islamists and al-Qaeda entrench themselves, the area will become a haven for terrorists plotting to spread their deadly wares as far afield as Europe and America, much as has previously happened in parts of Yemen, Somalia, Afghanistan and Pakistan.

The weakness of Mali’s own regime has helped the jihadists take over the country’s northern slice. A military coup in March was sparked by the army’s impatience with the civilian regime’s botched efforts to suppress an insurgency that has been rumbling off and on for many years by the disaffected Tuareg people (akin to the Berbers of north Africa) who make up a tenth of Mali’s 15m-plus population but who predominate in the north.

The fall of Muammar Qaddafi last year in Libya helped rekindle the rebellion, because many of the Tuareg who served his regime fled south-west to their remote Saharan fastnesses in Algeria, Niger and Mali, taking with them a mass of weapons. The strife in Mali has long had an ethnic rub, since the lighter-skinned Tuareg say that their black compatriots, who run Mali from Bamako, its capital in the south, treat them as second-class citizens.

Within weeks of the coup in March and the ensuing paralysis of government in Bamako, the northern rebels, spearheaded by a Tuareg separatist group, the National Movement for the Liberation of Azawad (MNLA), swept into the northern towns as the government forces fled. But in no time the separatists had themselves been outflanked by three vehemently Islamist movements: the Movement for Oneness and Jihad in West Africa, known by its French acronym, MUJAO, whose stronghold is Gao; Ansar Dine (“Defenders of the Faith”), led mainly by Tuareg fighters, in particular Iyad ag Ghali, whose stronghold is around Kidal; and al-Qaeda in the Islamic Maghreb (AQIM), a franchise of Osama bin Laden’s outfit, led by assorted Arab and other jihadists, with Algerian dissidents to the fore.

On November 6th a delegation from Ansar Dine was in Burkina Faso, where the president, Blaise Compaoré, is heading negotiations on behalf of ECOWAS. Ansar Dine has apparently stated its willingness to open peace talks and allow humanitarian supplies to be brought into northern Mali, by implication loosening its ties with al-Qaeda. Another Ansar Dine delegation has been in Algeria, by far the beefiest country in Mali’s vicinity. America and France have gone out of their way to persuade Algeria to sign up to the UN’s emerging counter-insurgency plan.

A vital piece in the diplomatic jigsaw is Ansar Dine’s enigmatic leader, Iyad ag Ghali (pictured above). A Tuareg native of Kidal in his 50s, he has a long and controversial record as both power broker and troublemaker in northern Mali. He has variously led rebellions and arranged the release of Western hostages; a bunch of French ones are still in rebel hands across the Sahara. Mr ag Ghali may also be wary of the Arab jihadists’ influence on the largely Tuareg rebels. Hence Mr Compaoré may think he can be wooed away from MUJAO and al-Qaeda.

But some say Mr ag Ghali’s influence is waning—and that his defection from the jihadist front would not make much difference. He founded Ansar Dine only, it is said, after failing to win the leadership of the Tuaregs’ MNLA, which is relatively secular. He may also have been embittered by his failure to win the chieftaincy of the Kidal Tuareg tribal confederacy. And despite Ansar Dine’s brutal application of sharia law, doubt has been cast on Mr ag Ghali’s own piety. His current Salafist bent may date from a recent stint as a Malian diplomat in Saudi Arabia. But before that he was said to enjoy a whisky, a charge his people deny. Cables published by WikiLeaks say he once walked into the American embassy in Bamako and asked for help to fight against al-Qaeda in the north. “They talk about the Islamic side,” says Timbuktu’s mayor, Hallé Ousmane, of Ansar Dine. “I think it is just a cover.” The group, he says, “wants territory in the desert to hide hostages and traffic in opium.”