Ten years after al-Qaeda-inspired bombings on Madrid commuter trains killed 191 people in March 2004, Spanish authorities are tackling a new wave of extremists.
"We are seeing the hatching of homegrown jihadism," said Fernando Reinares, one of Spain's top terrorism experts, at a gathering of specialists in Madrid this week.
"This is not new in Britain and France, but it is new in Spain and Italy."
Reinares estimates that about 60 jihadists have travelled from Spain to join extremists in Syria and Iraq in the past three years.
Spain's ambassador in Iraq, Jose Maria Ferre de la Pena, this week said that about 100 Spaniards had joined "jihadist militias" in conflict zones.
That is fewer than the hundreds from Britain, France and Germany who are thought to have gone to Syria to join the violent group calling itself Islamic State (IS).
But the relatively sudden emergence of the phenomenon has shocked Spanish authorities, who have arrested dozens of suspects accused of planning to join IS.
The group controls large swathes of Iraq and Syria and has killed several western hostages.
The latest video it has released showed jihadists beheading 18 Syrian prisoners and a US aid worker, Peter Kassig. Two Frenchmen were identified among the IS members.
That video "must make us more alert than ever, because the globalisation of this group is an undeniable threat", Spain's junior security minister Francisco Martinez said this week.
Girl, 14, jihadist suspect
Among the suspects arrested in Spain is a 14-year-old Spanish girl who was detained in August as she tried to enter Morocco allegedly en route to join IS, judicial sources said.
Spanish authorities have also identified hundreds of online profiles of radicals who support the group and who mentioned Spain in their messages, said Martinez.
In the latest case, the government said police on Wednesday arrested a Moroccan in Spain's southeastern Murcia region accused of "notable jihadist activity on the internet" and of trying to travel to Syria to join a "terrorist group" there.
Martinez said a wave of arrests of online suspects over the summer had prompted the government in September to intensify its level of vigilance for attacks.
Spain's military is currently helping train Iraq soldiers to fight IS, making the country a potential target for revenge attacks by extremists, the government warns.
Border trouble
A study by the Royal Elcano international studies institute found that the proportion of Spanish-born suspects among those detained in Spain for suspected jihadist crimes rose "exponentially" last year.
Seventy percent of such suspects arrested since 2013 were Spanish nationals, and of those nine out of 10 were born in Spain, said Reinares, co-author of the report.
He said "the vast majority" of suspected jihadists arrested in Spain in recent years were from Ceuta and Melilla, Spanish territories on the northern shore of Morocco.
In these small fenced-off cities, Spanish police guard Europe's only borders with Africa. Security officials have voiced concern about the presence of extremist cells in neighbouring Morocco.
Jose Antonio Vazquez, a chief inspector in the Spanish national police, warned that "jihadists could move relatively easily between north Africa and our country" via Ceuta and Melilla.
"It is an unusual national border compared to the rest of the European Union," with lots of people from Morocco crossing back and forth each day to trade in the Spanish territories, he told AFP.
'Lone wolf' fighters
Compared to some of its European neighbours who have suffered attacks, Spain has been "late" in adapting its laws to prosecute the latest terrorist cells, Reinares said.
In 2010, Spain broadened its anti-terrorism legislation to cover what were seen as new extremist threats such as recruitment and indoctrination.
Martinez said it is now planning a new penal reform and a new anti-radicalisation strategy to crack down on "passive training and indoctrination" which spawns "lone wolf" jihadists, particularly online.
Martinez also warned of so-called "foreign fighters" -- radicals who travel to conflict zones from other countries to train with violent groups and who authorities fear may then head to Europe.
"Spain is not so worried about the 60 or 70 fighters that have travelled from Spain to conflict zones," said Francisco Jose Vazquez, head of the international terrorism unit in Spain's military police, the Guardia Civil.
"We are more worried about the four or five thousand foreign fighters who instead of going back to their home countries, could end up in Spain."
Track Latest News Live on NDTV.com and get news updates from India and around the world