At least 14 people were killed and more than 100 others injured after drivers slammed into pedestrians in two quick-succession, separate attacks on Barcelona's most popular street and in another busy Spanish seaside town.
What happened?
An explosion in a house late Wednesday in Alcanar, about 200 kilometres (125 miles) south of Barcelona, left one person dead and seven wounded.
Initially treated as a random gas blast, police later linked it to the Barcelona assault, believing occupants of the house were preparing an explosive device inside. One of four suspects later arrested was detained in Alcanar.
Around 4:50 pm (1450 GMT) on Thursday, a vehicle ploughed into a crowd of pedestrians on the famous Las Ramblas boulevard in Barcelona.
The promenade in the heart of the city is one of Barcelona's busiest streets, normally thronged with tourists and street performers until well into the night.
Witnesses described scenes of chaos and panic, with bodies strewn along the boulevard as others fled for their lives.
The driver fled on foot. Police have since said he may be among several suspects killed in the hours since the mayhem started.
Second attack
Some eight hours after the Barcelona attack, an Audi A3 car hit pedestrians in the resort town of Cambrils, 120 kilometres (75 miles) to the south. Six civilians and a police officer were injured; one of the civilians, a woman, later died.
The five occupants of the car were killed by police.
When asked if the Barcelona driver may have been among those killed, Josep Lluis Trapero of Catalonia's police said "the investigation points in that direction," while cautioning that there was no "concrete proof".
Who are the victims?
Emergency services said at least 14 people had died and around 100 more were injured in the two attacks.
There were some three dozen nationalities among the dead and injured who came from countries as varied as France, Pakistan, Spain, the Netherlands, China, Venezuela, Mauritania, Australia, Britain and the United States.
At least one American was killed in the attacks, US Secretary of State Rex Tillerson said.
Rome said two Italian nationals were killed including a man who died in front of his wife and young children, and Belgium said one of its citizens was among the fatalities.
A 74-year-old Portuguese woman was also among the dead, the government said, while a man called Tony Cadman launched a Facebook appeal for his seven-year-old grandson who is missing.
So far France appears to have the most citizens among the injured, reporting 28 wounded with eight gravely hurt.
Who is behind it?
The Islamic State's propaganda agency Amaq claimed that "soldiers" from the jihadist group carried out the Barcelona attack, according to the SITE Intelligence Group which monitors Islamist websites.
"The executors of the Barcelona attack were soldiers of the Islamic State," Amaq said, quoted by SITE.
Police in the Catalonia region where both attack sites are located said they had arrested four suspects -- a Spaniard born in Spain's north African enclave of Melilla and three Moroccans.
One was held in Alcanar where Wednesday's explosion took place. The three others were picked up in the town of Ripoll, 100 kilometres north of Barcelona.
None of them had any criminal record where "terrorism" is concerned, Trapero said, although some had committed petty crimes.
Only one of those held has been identified as Driss Oukabir.
Police are also looking for his brother Moussa, as well as three other people according to the Catalonia-based La Vanguardia newspaper.
The suspects were preparing an even bigger attack but were thwarted in their plans after the house explosion in Alcanar destroyed "the material they needed to commit attacks of an even bigger scope," Catalonia police say.
Previous attacks in Spain
Spain was hit by what is still Europe's deadliest jihadist attack in March 2004, when bombs exploded on commuter trains in Madrid, killing 191 people in an attack claimed by Al Qaeda-inspired extremists.
In July 2015, a hooded attacker opened fire outside a hotel in downtown Barcelona near Las Ramblas boulevard, leaving two people injured, police said.
No suspected motive for that attack was given.