N IGERIAN TROOPS huddle around their captain for a briefing. Several rest their rifle muzzles in the sandy ground, which could block and damage them. During the assault on a terrorist training camp, many forget their training, firing wildly and running off their line of advance. After capturing it, they mill about and ignore the booms of incoming artillery. Finally they are brought up short by an angry Scotsman, who shouts: “Ibrahim, you’re dead!”

This less-than-successful mock attack took place near the town of Bobo-Dioulasso, in the west of Burkina Faso. It was part of an American-led training exercise earlier this year involving some 2,000 elite troops from more than 30 countries. These two-week war games are the most visible part of a big Western push to turn the tide in a bloody, forgotten war. Jihadists are sweeping across the Sahel, an arid swathe of scrubland on the southern edge of the Sahara that stretches most of the way across Africa. They are also causing mayhem in Somalia. America, Britain, France and other Western powers are trying to help local forces in at least 16 countries beat them back. It is not going well.

Since the collapse of the “caliphate” in Syria and Iraq, Islamic State ( IS ) has been looking for other places to raise its black flag. Africa, and especially the Sahel, is vulnerable. Governments are weak, unpopular and often have only a tenuous grip over remote parts of their territory. Abu Bakr al-Baghdadi, the leader of IS , sees an opportunity. In a video released on April 29th, to prove that he is not dead (his first such appearance in five years), the bearded zealot waxed enthusiastic about Africa. “Your brothers in Burkina Faso and Mali...we congratulate them for their joining the convoy of the caliphate,” he said, according to the SITE Intelligence Group, which monitors jihadist communications.

Major General Mark Hicks, who commands America’s special forces in Africa (and was in Burkina Faso for the war games) fears that IS is not the only terrorist group extending its franchise into his patch. “Al-Qaeda has taken a very serious long-term view of expanding here in the Sahel, and they’re seeing real success,” he says. His intelligence officers reckon that the groups they track contain about 10,500 jihadist fighters.

Most jihadists in Africa are fighting their own governments. But some attack Western targets. “If we don’t fight them here we will have to fight them on the streets of Madrid or Paris,” says a European intelligence officer.

One cannot generalise easily about African jihadist groups. Some are strictly local, having taken up arms to fight over farmland or against corrupt local government. Some adopt the “jihadist” label only because they happen to be Muslim. Many young men who join such groups do so because they have been robbed by officials or beaten up by police, or seen their friends humiliated in this way.

Other groups, such as al-Shabab in Somalia, are steeped in the teachings of al-Qaeda, the group behind the attacks on America on September 11th 2001. They tend to focus on spectacular atrocities, such as a truck bomb in 2017 in the Somali capital, Mogadishu, that killed almost 600 people. The most worrying groups are adherents of IS that seek to hold territory. An offshoot of Boko Haram, for example, is building a proto-caliphate in northern Nigeria.

Jihadist groups of all varieties are expanding their reach in the Sahel and around Lake Chad. Last year conflicts with jihadists in Africa claimed more than 9,300 lives, mostly civilian. This is almost as many as were killed in conflict with jihadists in Syria and Iraq combined. About two-fifths of those deaths were in Somalia, where al-Shabab frequently detonates car bombs in crowded streets. Many of the rest were in Nigeria, where the schoolgirl-kidnappers of Boko Haram and its odious offshoot, Islamic State West Africa Province, shoot villagers and behead nurses.

However, the area that aid workers and Western spooks worry about most is the Sahel. In Niger, Mali and Burkina Faso the number of people killed in jihad-related violence has doubled for each of the past two years, to more than 1,100 in 2018. And the violence is spreading, spilling across borders and threatening to tear apart poor, fragile states with bad rulers and swelling populations. Such places are already beset by droughts, possibly caused by global warming. Over the longer term “the Sahel is our biggest worry,” says Mark Lowcock, who is in charge of emergency relief at the UN . Peter Maurer, the president of the International Committee of the Red Cross, frets that conflict and climate change are prompting huge flows of migrants out of the Sahel.

Fear of refugees is one of the main reasons why European military powers are trying to stabilise the region. France has 4,500 troops fighting jihadists there. Germany and Italy each have about 1,000 soldiers in Africa. Britain has set up two specialised infantry units dedicated to training African soldiers in Nigeria and Somalia. America, which is more concerned about terrorism than refugee flows in this part of the world, has more than 7,000 military personnel in Africa.

The majority of Western troops do not fight jihadists directly—except in Somalia, where drone-fired missiles have killed many of al-Shabab’s fighters. Most are training local forces. They often have to start with the basics. In Nigeria, for instance, jihadists often sneak up and overrun army bases because the bush around them has not been cleared. Or they start shooting at them with a small force to goad the defenders into using up their ammunition firing back, leaving them helpless when the main attack begins.

Efforts to contain the spread of jihadism by training local armies or killing insurgent leaders are not obviously working. Take Mali, where in 2012 Tuareg separatists and jihadists allied to al-Qaeda swept out of the desert and conquered the north of the country using weapons looted from the arsenals of Libya’s dead dictator, Muammar Qaddafi. The rebels seemed ready to march on the capital, Bamako, and the south, which contains 90% of the population and sustains most of the economy.

French troops pushed them back from the main cities. But not even their expertise and firepower could defeat the rebels, who simply melted back into the desert. There they have survived a seven-year-long counterinsurgency campaign. Pundits in Paris are calling Mali “France’s Afghanistan”. And with good reason. The UN now has more than 16,000 peacekeepers in Mali, of whom 195 have been killed, making it the blue helmets’ most dangerous mission since its start in 2013. Nonetheless, the jihadists have continued to spread south into Niger and Burkina Faso.

The government of Mali has shown little interest in trying to restore security in the northern half of the country, contenting itself with holding the gold-rich south. “They have basically ceded the territory and aren’t willing to fight for it,” complains a Western army officer. Worse still, the government has allowed—if not actively supported—the formation of pro-government ethnic militias that are responsible for a rapidly increasing number of attacks on civilians from minority groups (see article). A flood of weapons from the Gulf of Guinea feeds the mayhem. There are so many assault rifles in Mali that the price has fallen from $600 two years ago to $260 today, says an official.

Western governments and armies have started to focus less on Mali and Nigeria and more on Niger and Burkina Faso, hoping that these countries can act as bulwarks to halt the spread of jihadism. “We have a window of opportunity to help this country draw a line that they can hold,” says Andrew Young, America’s ambassador to Burkina Faso.

Unfortunately, many of the mistakes that were made in Mali are also being made in Burkina Faso. Militias are proliferating; a cycle of ethnic violence has begun.

Too little is being done to fix the underlying problems that fuel conflict, such as failing agriculture, poor governance and poverty. Local elites seldom want to end the corruption that enriches them, or allow the kind of democratic accountability that might limit their power.

Furthermore, the threat of jihadism has prompted some Western governments quietly to stop promoting democracy in Africa, just as during the cold war, when they propped up awful regimes if they were anti-communist. A similar approach seems evident now: almost any ruler who is anti-jihadist can seem a suitable ally. Earlier this year, for example, French warplanes bombed rebels in Chad to protect Idriss Déby, who has ruled since 1990. In Cameroon special forces trained by the West have been implicated in brutal abuses against opponents of Paul Biya, who has been president since 1982.

The Sahel is so unstable that foreign troops will probably be there for years. But unless local governance improves, they will not eliminate the jihadist threat. As one Western officer muses: “Are we just building sandcastles at low tide?”