At least 15 people were killed and more than 100 injured in twin attacks in which vehicles were used to mow down pedestrians on Barcelona's most popular street and in Cambrils, a busy seaside resort town.
Around 4:50 pm (1450 GMT) on Thursday, a white van ploughed into a crowd of pedestrians on the famous Las Ramblas boulevard in Barcelona.
One of the city's busiest streets, the promenade is normally thronged with tourists and street performers until well into the night.
The van rammed through the crowds for more than 500 metres (yards), leaving bodies strewn along the boulevard as others fled for their lives. The driver fled on foot.
About eight hours later, just after midnight local time (2200 GMT), an Audi A3 carrying five suspects smashed into pedestrians in the resort town of Cambrils, about 120 kilometres (75 miles) south of Barcelona.
Six civilians and a police officer were injured before the vehicle was halted at a police check-point where an officer shot and killed four of the suspects, who were wearing fake explosive belts and carrying knives.
But one man got away, and managed to slash a woman who later died of her wounds, before he was also shot dead.
The attacks killed at least 15 people and wounded over 100, with tourists from three dozen countries perishing in the carnage.
Among the dead and the injured were nationals from Australia, Britain, China, France, the Netherlands, Mauritania, Pakistan and Venezuela.
At least one American was also killed in the attacks along with three Italians, a Portuguese woman and her granddaughter and a Canadian. Among the dead are two children.
So far France appears to have the most citizens affected, with 30 wounded, eight of whom are in serious condition.
Both attacks were claimed by the Islamic State group.
Officials suspect at least 12 people of involvement in the attacks, many of them Moroccans.
Four suspects have been arrested -- a Spaniard and three Moroccans, one of whom is Moussa's older brother Driss, 27.
They were charged on Tuesday with terror offences over the rampage in Barcelona and in the seaside resort of Cambrils further south.
The other eight were killed by security forces or blown up in an explosion believed accidentally detonated in the attackers' bomb factory.
Police on Monday shot dead Younes Abouyaaqoub, the 22-year-old Moroccan who they believe drove the Barcelona rampage van, in Subirats -- about 60 kilometres (37 miles) from the Catalan capital.
After the attack on Las Ramblas, he hijacked a car to make his getaway, stabbing to death its driver. The Ford Focus was found in a town just outside of Barcelona.
Three of the five suspects killed in Cambrils have been identified as Moroccan nationals: Moussa Oukabir, 17; Said Aallaa, 18; and Mohamed Hychami, 24.
The last two suspects died in an explosion late Wednesday at a house in Alcanar, about 200 kilometres (125 miles) south of Barcelona, where police found around 120 gas canisters.
One of them was a Moroccan imam, Abdelbaki Es Satty, suspected of having radicalised youths who carried out the attacks. The other fatality has not been identified.
Police believe the men had accidentally set off explosives they were preparing for "one or more attacks" in Barcelona.
The cell was planning "an attack on an even greater scale, targeting monuments," according to a judicial source.
Traces of the ingredients needed to make TATP -- the explosive of choice for the IS group -- were also detected in the likely bomb factory, which is still being combed by forensic experts.
At the same time, French Interior Minister Gerard Collomb told BFMTV that the Audi used in Cambrils was detected by speed cameras in the Paris region while making "a very rapid return trip" days before the Spanish attacks.
Although Spain has largely avoided the Islamist bloodshed that has blighted Europe in recent years, it remains the scene of the continent's deadliest jihadist attack, when bombs ripped through commuter trains in Madrid in March 2004, killing 191 people.
That attack was claimed by Al Qaeda-inspired extremists.