The terrorist attack on an Algerian natural gas plant that left dozens of hostages and militants dead has demonstrated how a failing Algerian insurgency transformed itself into a regional threat, partly by exploiting the turmoil unleashed by the Arab Spring revolts.
Al-Qaeda's branch in Algeria retreated into a Sahara no man's land between Mali, Algeria and Mauritania after it was largely defeated by the Algerian army in a 10-year war in the 1990s that claimed 200,000 lives. There it grew rich on smuggling and hostage-taking, gained new recruits and re-emerged stronger than ever, armed with looted high-tech weapons from Libya's 2011 civil war.
The audacious assault last Wednesday on Algeria's Ain Amenas gas complex by a multinational band of Islamists shows how long-simmering ethnic tensions in Mali, a civil war in Algeria and a revolution in Libya have combined to create a conflict spanning the deserts and savannahs of both North Africa and West Africa.
Algeria's Islamists were driven south into the desert by the military's brutal counterinsurgency tactics - a take-no-prisoners approach vividly on display in the resolution of the latest hostage crisis.
Factions of Al-Qaeda in the Islamic Maghreb became rich in the lawless desert by smuggling guns, drugs and cigarettes and by kidnapping foreigners for ransom. Soon they became involved in the longstanding disputes of the desert Tuareg against the government in Mali, whom the tribesmen felt ignored or abused them.
One of their prominent leaders was Moktar Belmoktar, who made millions smuggling and kidnapping and went on to mastermind the attack on the Ain Amenas plant.
While taking up the Tuareg cause in northern Mali, these al-Qaeda-allied groups decided to use their new-found strength to settle scores against old opponents like Algeria and the West.
"It seems that Moktar has tasked himself with the internationalization of the Mali conflict," said William Lawrence, the North African analyst for the International Crisis Group. "There's no question there is struggle between different groups in the Sahel and Sahara to have the upper hand in claiming the jihad mantle in the region."
Belmoktar fell out with the local al-Qaeda franchise, the Al-Qaida in the Islamic Maghreb (AQIM), and formed his own northern Mali-based group in December called the Masked Brigade. He promised to attack those threatening the radical Islamist mini-state that was emerging in northern Mali.
"We threaten everyone who participated in and planned for the aggression against our Muslim people due to their implementation of Islamic Shariah law on our land," he announced in December on jihadi websites. "You will taste the heat of war in your countries and we will attack your interests."
With the money to be made in smuggling and kidnapping, all that was missing was easy access to heavy weaponry. That changed in 2011, and weapons came cascading across the borders when Libya fell apart and dictator Moammar Gadhafi's vast arsenals of oil-bought weapons were looted.
What began in January 2012 as a secular revolt of disaffected Tuaregs hoping to carve out a homeland in northern Mali was soon hijacked by al-Qaeda and allied extremist groups.
With their new weapons, money and men, Algerian militants like Belmoktar could now do what had never been possible before - hit oil-rich Algeria's strategic energy infrastructure in the remote desert.
National borders were no impediment to these heavily armed fighters in four-wheel drive vehicles.
"AQIM and other militant Islamist groups' control over northern Mali and weak security along Libya's borders has provided the organization with greater operational freedom," noted Arun Pillai-Essex, an analyst with Maplecroft, a risk analysis group, who said AQIM has also been able to capture weapons from the Libyan and Malian armies.
Where will the Islamists strike next?
Another attack on an Algerian energy installation is doubtful, analysts say. Already heavily guarded, security will no doubt be vastly increased and there are suggestions that the Ain Amenas attack only succeeded by having some type of inside help.
France and its Western allies fear AQIM could metastasize its terrorism into Europe if left unchecked.
In the last two weeks, France has been taking the fight to AQIM with punishing air strikes against the vast territory the group controls in northern Mali - raising questions about whether the group's fighters will have much time to think about new terror attacks.
"It is one-off episode, they got lucky," said Riccardo Fabiani, North Africa analyst of the Eurasia group. "I would think that the next attacks are going to target other countries. Mauritania could be an easy target, Morocco or any ECOWAS country or possibly in Libya."
The attack has also pushed France and Algeria - two nations with fraught relations due to bloody colonial ties - closer together over the need to combat these groups.
Prior to the attack, Algeria had long publicly opposed France's call for armed intervention to deal with the rise of extremist groups in northern Mali, citing the threat to regional stability and the chances of the crisis spilling over into its own desert regions.
Now, with the fight brought to Algeria's doorstep, al-Qaeda-linked groups will be facing their old implacable enemy once more.
Unlike other Western nations, French officials refused to criticize Algeria for its strong-fisted handling of the Ain Amenas hostage ordeal.
"When a country is attacked in this way, and its own sovereignty is jeopardized, it decides on how to respond with its own army," French Defense Minister Jean-Yves Le Drian said Sunday on France-5 TV.
Throwing more military operations at al-Qaeda, however, is not going to solve the underlying problem, warned Lawrence, the North Africa analyst.
"This is linked to the Libyan conflict, it's linked to the Mali conflict, it's linked to 50 years of struggle by the Tuareg, it's linked to 20 years of struggle in Algeria," he said.
Ultimately, he says, the countries of North and West Africa, not to mention Europe, will have to address the conditions that allowed al-Qaeda to flourish in this impoverished region.
"A security response is at best a partial response. Until a robust political, humanitarian and economic effort is implemented, the security effort won't solve these problems," Lawrence said.