At least 14 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 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. So far police have yet to confirm his identity and it remains unclear whether he was killed in subsequent police raids or is still at large.
Press reports on Sunday said he stole a car and stabbed to death its driver, who, if confirmed, would be the 14th victim of the Barcelona attack.
About eight hours later, just after midnight local time (2200 GMT), an Audi A3 carrying five suspects rammed 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 two attacks killed at least 14 people and wounded around 100, with tourists from three dozen countries caught up 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, an elderly Portuguese woman and a Canadian.
So far France appears to have the most citizens affected, with 28 wounded, eight of whom are in serious condition.
Both attacks were claimed by the Islamic State group.
Police suspect at least 12 people of involvement in the attacks, many of them Moroccans.
Investigators are hunting for Younes Abouyaaqoub, a 22-year-old Moroccan, with unconfirmed reports suggesting he might have been the Barcelona van driver.
But police say the driver might have been one of the five killed in Cambrils, saying the probe "points in that direction".
Three of those killed in Cambrils have been identified as Moroccan nationals: Moussa Oukabir, 17; Said Aallaa, 18; and Mohamed Hychami, 24.
Another four suspects have been arrested, a Spaniard and three Moroccans, one of whom is Moussa's older brother Driss, 27.
The last two suspects are believed to have died in an explosion late Wednesday at a house in Alcanar, about 200 kilometres (125 miles) south of Barcelona, where police found around 30 gas canisters.
Police believe the men had accidentally set off explosives they were preparing for "attacks of an even bigger scope".
The probe was also turning to the role of a missing Moroccan imam, Abdelbaki Es Satty, who is believed to have radicalised the young attackers.
On Saturday, police raided the imam's apartment in Ripoll, his flatmate, who would identify himself only as Nourddem, told AFP.
Spanish media reports, quoting police sources, said the officers were seeking DNA traces in the apartment to compare with body parts found in the Alcanar explosion.
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.