To fight a war, you need three essentials: weapons, fighters and cash. And the al-Qaeda-linked groups in northern Mali now being bombed by France have enjoyed a rich supply of all three ingredients, thanks to the downfall of Libya’s dictator Muammar Gaddafi, as well as, ironically, Western governments themselves, which have paid Islamic groups millions of dollars over the past few years to free European hostages in the vast Sahara Desert. “The jihadi groups were flush with cash, and were in a position to buy whatever was within reach,” says François Heisbourg, a security expert and chairman of the International Institute for Strategic Studies in London. “How many arms depots did Gaddafi have? Well over a thousand. So there is still a lot of stuff sloshing its way in all directions.”

The pipeline of weapons to Mali’s insurgents from Libya’s old regime has been an anxiety for African and Western governments ever since Gaddafi was killed in October 2011. The Libyan leader was a prolific arms buyer, spending billions in oil revenue during his last years on state-of-the-art weaponry and leaving behind miles of unsecured warehouses filled with rockets, machine guns, ammunition and antiaircraft systems, much of which had never been unpacked. Within hours of Gaddafi’s death, many ethnic Tuareg fighters from northern Mali, who’d fought alongside Libyan forces as mercenaries, retreated across the Sahara, carrying as much weaponry as they could stuff into their pickup trucks. The patchwork of ethnic separatist groups and Islamist militias that seized Mali’s north this year cemented their control from the muzzles of these guns.

But nearly 16 months on, that arms pipeline has yet to be halted. A report last November by the Civil-Military Fusion Centre, a research organization run by NATO’s Allied Command Operations in Norfolk, Va., said Tuaregs had continued selling quantities of weapons from Libya’s stockpiles to the National Movement for the Liberation of Azawad, the major rebel group that seized control of northern Mali last March.

Despite the mounting threat, Western and African governments delayed action for months, and decisions that might have been taken last year were not. Daunted by the task of securing thousands of miles of remote desert borders, which sand tracks have been used by camel herders and tribesmen for centuries, officials expressed concern, but did little concrete. While Mali is separated from Libya by two huge desert territories, Algeria and Niger, both countries’ borders are extremely porous, and neither government has had much motivation to halt the weapons flow. The attitude of Algeria, which has the region’s biggest military, is “benign neglect,” Heisbourg says. “As long as the jihadis kept to themselves and operated outside of Algeria, the Algerians didn’t want to get involved.”

Although U.S. drones have operated in the region for months, American officials publicly insisted that Africa needed to take the lead against Mali’s rebels. The head of the U.S. military’s Africa Command, General Carter Ham, told the French newspaper Le Monde last November, “Our most important activity, not only for us, is to help countries in the region to enhance security at their borders. Mauritania, Libya, Tunisia, Burkina Faso, Niger, are threatened by these networks across their borders,” he said. That same week, Ham told students in Paris, at an event attended by TIME, that confronting Mali’s jihadists was immensely complicated, and would likely take months to plan given the intricate web of regional organizations involved and the fact that the central government in Bamako, made dysfunctional following a military coup in March, had a loose grip on power and little capacity to regain control of the north on its own.

Two months later, Western and African nations are now scrambling to act, jolted into action by the southbound advance last week by the jihadist fighters, which threatened to turn all of Mali — a longtime U.S. ally that’s geographically double the size of Texas — into a failed state overrun by Islamist militant factions. Having appealed for international intervention for months, French President François Hollande deployed his special forces last Friday and ordered bombing raids on rebel camps in northern Mali, disrupting the Islamists’ advance and sending many fighters fleeing into the desert, according to French Defense Minister Jean-Yves Le Drian. He told reporters on Monday that the rebels based in the east of the country had been halted, while Malian and French forces were still battling “extremely well-armed groups” in the west. Monday evening, French special forces led an all-night bombing campaign in Diabaly in an effort to dislodge Islamist militants who seized the area, including its strategic military camp. The bombings took place as a convoy of 50 armed trucks carrying French troops crossed into Mali from Ivory Coast, as France prepares for a possible land assault.

Even when the insurgent offensive is pushed back, choking off Libya’s weapons supply once and for all could be difficult. And that’s hardly the only arms-smuggling route into Mali: in Mauritania, to Mali’s west, weapons vanished from two government stores last month. NATO is even working to try to destroy some of the country’s weapons stocks, which officials believe supply insurgent groups in the region.

The problem is that the Sahel region of North Africa includes some of the world’s poorest countries, with criminal activities, including arms and drug trafficking, comprising some of the most profitable enterprises, especially as there are customers who can afford those wares. Heisbourg and others believe jihadist groups are well financed, having made fortunes through ransom payments for hostages from Switzerland, Spain, Austria, France and elsewhere. Although European governments have denied paying ransoms, most experts in the region believe it has been common practice. For jihadists, says Heisbourg, “it has been a very, very lucrative business.”

After months of dithering on what to do about Mali, the Prime Ministers of Algeria, Libya and Tunisia finally agreed on Saturday to begin joint border patrols and to begin sharing intelligence, including about the region’s drug traffickers, whom officials believe finance the operations of al-Qaeda in the Islamic Maghreb. Tunisia’s President Moncef Marzouki told France 24 he believed his country “is becoming a corridor for Libyan weapons,” which then through remote desert routes in Algeria where al-Qaeda militants are closely tied to those in northern Mali. He described the insurgency as “a hornet’s nest that can threaten the security of all the countries, including Tunisia.” That nest has finally been cracked open.