Spain is evacuating all its aid workers and three other foreign nationals from refugee camps in Tindouf, western Algeria, due to "growing insecurity".
Foreign Minister Jose Manuel Garcia-Margallo said 12 Spaniards, two French nationals and an Italian would arrive in Madrid by military plane on Sunday.
Earlier this month three European aid workers seized from a refugee camp near Tindouf were released by a rebel group.
The group said it was an offshoot of al-Qaeda in the Islamic Maghreb (AQIM)
Mr Garcia-Margallo said the decision had been taken after reviewing "well-founded evidence of a serious increase in insecurity in the region".
He said that the north of neighbouring Mali had been "converted into a platform for terrorism".
Northern Mali was seized by Islamist and Tuareg rebels after a coup in March.
An uneasy alliance between the two has since collapsed, leaving al-Qaeda Islamists in control of all three of the region's main cities - Timbuktu, Gao and Kidal.
Thousands of people have fled the region and regional bloc Ecowas has announced plans to send 3,000 troops to intervene.
Mr Garcia-Margallo said on Saturday that Spain would be willing to support an Ecowas mission in the region, although it was not clear what form that support might take.
Last October, Spanish aid workers Enric Gonyalons and Ainhoa Fernandez along with Italian colleague Rossella Urru were seized from the Rabuni refugee camp near Tindouf by rebels from the previously unknown Movement for Oneness and Jihad (Mujao).
Negotiators who organised their release this month revealed they had been freed after a prisoner swap involving two Islamists being held in Mauritania.
There were also reports of a ransom being paid, but this was not confirmed by the negotiators.