Spanish police have shot dead five attackers who ran over people in the seaside town of Cambrils.
Special forces were deployed to Cambrils just hours after a van ploughed into crowds in Barcelona's famous Las Ramblas boulevard in which 13 people were killed and at least 100 others injured.
The Catalan government says the two attacks are linked.
Seven people were hurt when the attackers ran them over in an Audi A3
The suspects in Cambrils were wearing what transpired to be fake explosive belts and a bomb squad carried out several controlled explosions, police said.
Six civilians and a police officer were hurt when the attackers ran them over in an Audi A3.
The town's mayor, Cami Mendoza, said the suspects centered their attack on the narrow path to Cambrils' boardwalk.
The car was removed from the scene on Friday morning
:: LIVE: Latest updates on Spanish terror
Footage of the operation in the early hours of the morning at the popular seaside resort, situated 62 miles southwest of Barcelona, showed bystanders running for cover amid the sound of gunfire.
Screams and police sirens could be heard in another clip filmed from inside a restaurant as diners ran for cover after hearing gunshots.
The van used in the attack in Barcelona is towed away from Las Ramblas
Joan Marc Serra Salinas, a 21-year-old waiter, said he heard many gunshots - adding: "And shouting. And more shouting. I jumped onto the beach and didn't move."
Police said the Cambrils plot was linked to the earlier attack involving a white Fiat van - the driver of which remains at large and is the focus of a police manhunt - and an explosion 100 miles away in Alcanar.
Three people have been arrested over the Barcelona attack .
One has been named by police as Moroccan national Driss Oukabir, who was detained in the Catalan town of Ripoll, about 50 miles north of the Catalan capital.
A second suspect - a Spanish national from Melilla, a Spanish autonomous city on the north coast of Africa which shares a border with Morocco - was detained in Alcanar, where one person was killed another injured in the blast.
Islamic State said it was responsible for the Barcelona attack, in a statement through its propaganda agency Amaq.