REUTERS/Susana Vera
While geographically distant from the battlegrounds of Iraq and Syria, Spain has still become a focal point for terrorism-related activity because of its history and position between North Africa and Western Europe.
In the years since the devastating 2004 train attacks in Madrid - the deadliest attack in Europe so far this century - Spain has intensified efforts to uncover, monitor, and disrupt terrorist activity and plots - though such networks have been resilient.
Terrorism is not new in Spain. Starting in 1961, the ETA, a Basque separatist movement, launched hundreds of attacks around the country, killing more than 800 civilians and security personnel. (The ETA announced the end of its armed campaign in 2011.)
But prior to the March 2004 train bombings, carried out by Al Qaeda, Spanish authorities gave little attention to Islamist terrorism.
Imad Eddin Barakat, one of the founders of Al Qaeda in Spain, was able to see off fighters bound for Bosnia or Chechnya from the capital's Barajas airport, according to El Pais. And he was able to greet wounded fighters in Madrid when they returned, shepherding them to state-run hospitals for treatment.
(AP Photo/Paul White, File)
Since then, Spanish security forces have led the continent in their anti-terrorism efforts. They have made more than 700 arrests, and dozens of convictions have yielded 120 prisoners and no attacks since March 2004.
This record has been secured in part by proactive measures as well as domestic factors. Hundreds of agents from the country's Civil Guard, National Police, and National Intelligence Center cull social-media networks, investigate domestic activity, recruit informants, and research ISIS and other groups like it.
In comparison to other European countries, in Spain, "The Muslim community and the level of radicalization are not the same, xenophobia has not taken hold, and the risk is proportionate to the number of combatants who have traveled to Syria or Iraq," a police chief told El Pais. "In our case there are very few."
(Spanish Interior Ministry, via AP)
Another analyst attributed it to a variety of factors as well.
"Here we don't have ghettos as they do in France. The integration of the Muslim population is greater, and there is an incipient second generation." (Though members of this second generation with extremist leanings may find it easier to obscure their activities.)
At present, police in Spain are monitoring over 1,000 people, while courts there are investigating 259 people, and 500 phones are being tapped, according to information seen by El Pais.
But terrorism and related activities continue to be thwarted in Spain, particularly recruiting and logistical support. The North African exclaves of Melilla and Ceuta are a locus for this activity.
When six suspects were arrested in Ceuta in early 2015, the country's interior ministry said they were "prepared physically as well as mentally for jihad."
Melilla is only 12 square kilometers in size but has five security agencies operating within it, including Morocco's General Directorate for Territorial Surveillance and Israel's Mossad (though some Spanish officials regard the Moroccans warily).
"Between people from Morocco and Melilla, including targets and associates, we have 400 people on the radar, although that's not to say that they are all potential terrorists," one Civil Guard officer told El Pais.
Thomson Reuters
In Ceuta, where 600 people of interest are located, the challenges of monitoring suspects on the country's fringes comes to the fore.
"They take a lot of security measures and when they cross the border we lose track of them," one officer told El Pais. That the North African exclaves are frequently the site of mass border-crossing attempts by migrants no doubt complicates the task.
In total, 150 people have traveled from Ceuta and Melilla, as well as Spain's two largest cities, Madrid and Barcelona, to fight in Syria. While the conditions and locations of the exclaves makes Islamist activity more likely, officials have downplayed the likelihood of attacks.
REUTERS/Albert Gea
Barcelona and Madrid, however, present target-rich environments.
The Catalan capital has a long history of radical Islamism.
Between 1996 and 2013, nearly 29% of people sentenced for jihadist-related terrorism offenses were arrested in the Barcelona province.
Madrid has also been on high alert over the last few years in response to attacks elsewhere in Europe.
In December, authorities in northern Spain apprehended suspect believed to be plotting a Christmastime truck attack in the capital, similar to the deadly incidents in Nice, France, and Berlin.
ISIS, relatively new to the jihadi scene, has also presented challenges for Spanish authorities.
The terrorist group has seized on Spain's long history of Muslim presence, which stems from Umayyad caliphate's eighth-century expansion there and the efforts of European monarchs to recapture it over the next 700 years.
"Oh dear Al Andalus," a French member of the group said in a video released in early 2016, using an Arabic name for Spanish territory. "You thought that we had forgotten you ... no!"
"No Muslim can forget Cordoba, Toledo or Xativa," he said in the video, which also featured him executing five prisoners. "Al Andalus, have patience ... you are not Spanish or Portuguese but Muslim."
A string of arrests over the last two years illustrates how ISIS' rise has come to color terrorism-related activity - recruitment as well as logistics - going on in Spain.
REUTERS/Jesus Blasco de Avellaneda
In early 2015, police arrested eight suspected members of a jihadi cell believe to be plotting attacks and recruiting for groups like ISIS. In August 2015, police in Spain and Morocco arrested 14 people suspected of planning attacks in those two countries and of sending fighters to join ISIS in the Middle East.
In February 2016, nationwide raids yielded seven arrests in Spain, breaking up a suspected ISIS cell responsible for sending goods to support fighters in Iraq and Syria. In April 2016, police stopped a couple linked to ISIS before they could go to Morocco with their son. In September, Spanish police arrested several people accused of promoting ISIS and acting as go-betweens for the group in Europe.
That was followed by a flurry of arrests in November, including four people in Ceuta suspected of trying to recruit children for ISIS, and four people in mainland Spain suspected of running a people-smuggling network that could have brought ISIS members to Europe.
In April this year, Spanish police arrested nine people with possible ties to recent deadly attacks in France and Belgium. A day later, police arrested two men suspected of recruiting for the terrorist group and of helping fighters travel back to Europe.
REUTERS/Marcelo del Pozo
An early 2015 report also indicated that Spain had long been a major finance hub for terrorists in Syria and Iraq, using a network of businesses to transfer money. The network made use of the informal and hard-to-track hawala system, which facilitates transfers without physically moving the money.
At the time, the network of hawala dealers in Spain was also reportedly used to pay jihadists from the country who had gone to Syria. "We hadn't seen anything like this since the Afghan War," an one intelligence agent said at the time. "Not only do they recruit fighters here but they are also receiving money from here."
In addition to finance, investigations in early 2016 linked shipping activity in Spain to groups supporting ISIS and other groups, like the Al Qaeda-affiliated Al Nusra. The groups were mainly shipping used clothes, but also weapons and other material, to Syria and Iraq under the guise of humanitarian aid.
It also marked the first time Spain-based groups were found to be involved in logistical support, rather than just recruitment.
Spanish government
Muslim communities in Spain have not only praised authorities' efforts to disrupt terrorist activities, but they also called for more work to address underlying conditions that push people toward extremism - like poverty and insecurity that push youths in Ceuta's heavily Muslim neighborhoods toward radicalization.
"The police are doing things well, with recruitment slowing down," Laarbi Mateis, the secretary of the Islamic Commission in Ceuta, told El Pais. "But all of the efforts are related to security and not to education. We need social measures."
Though Spain has avoided deadly Islamist attacks since the 2004 train bombings, authorities there admit the risk of another attack is high, but they're confident in their methods.
"We don't leave a single face without investigation," Dolores Delgado, public prosecutor coordinator for terrorism cases at the Spanish High Court, told El Pais. "We could miss something, of course, but we're always very clear what we are looking for. I believe we are at the forefront."