A 35-year-old Italian was among 14 killed, mowed down in front of his wife and young children in Barcelona when a driver rammed his van through crowds on the busy Las Ramblas boulevard on Thursday, before fleeing on foot.
Police said they shot dead five "suspected terrorists" who had knocked pedestrians down in the Catalan seaside resort of Cambrils in a second attack in the early hours of Friday, and arrested four others as Spain reeled from the deadly violence.
Spanish emergency service claims Pakistanis among dead, injured in attacks
Catalonia's regional police identified three of the suspects who were killed as Moroccan nationals.
They were Moussa Oukabir, 17, Said Aallaa, 18, and Mohamed Hychami, 24.
Police said Friday they suspect 12 people of involvement in the attacks: the five who were killed, four who were arrested and three who have been identified but who remain at large.
Officials suspect that two of these three may have died in a blast at a house in the town of Alcanar, about 200 kilometres (140 miles) south of Barcelona on Wednesday evening.
Initially treated as a random gas blast, police later linked the explosion to the Barcelona assault, believing occupants of the house were preparing a larger attack, possibly a vehicle bomb, with the use of gas canisters and slipped up.
Police removed dozens of gas canisters from the house, according to an AFP photographer at the scene.
"They were preparing one or several attacks in Barcelona, and an explosion in Alcanar stopped this as they no longer had the material they needed to commit attacks of an even bigger scope," said Josep Lluis Trapero of Catalonia's police.
After the explosion the suspects quickly went on to commit "more rudimentary" attacks. These involved the vehicles ploughing into pedestrians in Barcelona and Cambrils, he added.
The Cambrils suspects had an axe and knives in the car as well as fake explosive belts stuck to their bodies, said police.
Both Spanish attacks followed the same modus operandi.
Drivers deliberately targeted pedestrians with their vehicles, the latest in a series of such assaults in Europe.
The Mediterranean resort of Nice in France was particularly hard hit on July 14, 2016, when a man rammed a truck into a crowd, killing 86 people.
Otso Iho of Jane's Terrorism and Insurgency Centre said the Spanish assaults, which stretched out over two different cities, appeared to be "a much higher level of coordination than has been typically present in previous attacks."
It is also believed to be the first time IS has claimed an attack in Spain.
In a poignant moment Friday, Prime Minister Mariano Rajoy, King Felipe VI and the president of Catalonia -- where both attacks took place -- held a minute of silence in Barcelona. It was followed by the crowd applauding and shouting "not afraid".
But in a sign of the tensions sparked by the attacks, about 20 far-right militants tried to protest at the march. Some held up signs reading "No More Mosques" or "Refugees not welcome anymore".
Scuffles broke out between the far-right militants and the march participants.
Details started to emerge Friday on the identity of victims, as did tragic stories of families ripped apart.
Witnesses in Barcelona described how the van pushed through the crowd, leaving bodies strewn along the boulevard as people fled for their lives, screaming in panic.
"We were on the city tour bus, we were 20 feet from the accident when it happened," said Alex Luque, a 19-year-old student from New York.
"We heard the van and the impact with people and then we saw people running."
Then just eight hours later attackers struck in the early hours of Friday in Cambrils. An Audi A3 car rammed into pedestrians, injuring six civilians and a police officer. One civilian, a woman, later died of her injuries.
The police shot dead the five attackers. They also said they had arrested four suspects -- three Moroccans and a Spaniard.
Police said they have not yet identified who drove the white van that sped into crowds in Barcelona.
There were some three dozen nationalities among the dead and injured, from countries including Algeria, Australia, China, France, Ireland, Peru and Venezuela, according to Spain's civil protection agency.
The Catalan government said seven victims of the attacks had been identified - five Spanish nationals, an Italian and a Portuguese.
Fifty-nine injured remained in hospital, including 15 who were in critical condition, the Catalan interior ministry said.
The Spanish government must now decide whether to raise the terror threat level from four to five (the maximum) during the height of the tourist season.
Spain, the world's third most popular tourism destination with the industry accounting for 11 percent of the country's economy, had until now been spared in the recent wave of extremist attacks that have rocked nearby France, Belgium and Germany.
It had even seen a surge in tourists as visitors fled other restive sunshine destinations such as Tunisia and Egypt.
World voices solidarity with Spain after terror attack
But it is no stranger to militant attacks.
In March 2004, it was hit by what is still Europe's deadliest, when bombs on commuter trains in Madrid killed 191 people in an attack claimed by Al Qaeda-inspired extremists.
Spain has also had to deal with a decades-long campaign of violence waged by Basque separatist group ETA, which only declared a ceasefire in 2011.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ