Police in Spain say five people have been shot dead in the Catalonian coastal town of Cambrils as officers intercepted a second van attack.
Earlier, at least 13 people were killed when a van rammed into pedestrians on Las Ramblas in the Spanish city of Barcelona.
More than 100 others were injured.
15 are in a critical condition and authorities say the death toll could rise.
Police have arrested three men, although authorities say the driver of the van is still at large.
Gunfire was heard during the incident in Cambrils and local residents were warned to stay indoors.
The attackers were said to be wearing explosive belts and had attempted to drive their car into a group of people.
But the vehicle overturned and they were shot dead by the police.
Seven people were injured including an officer.
Investigators are now linking both incidents to the death of another person who was killed in an explosion at a house in Alcanar around 100 kilometers southwest of Barcelona on Wednesday night.
In a separate shooting, police killed a man who had driven a car into a police checkpoint in Barcelona, though they have no evidence if this was connected to the other attacks.
The Catalan emergency services urged people via Twitter to avoid going out or undertaking any other type of movement that is not "strictly necessary" to facilitate police operations.
Ethan Spidey, 25, told The Independent there was a “stampede” as tourists and locals sprinted away from the scene of the Barcelona attack.
He said: “I was with my boyfriend just about to cross La Rambla and all of a sudden there was an immediate stampede and police shouting at people to run."
“I saw a young child knocked over and picked them up but everyone was just running."
World leaders have condemned the incident.
Spain's Prime Minister Mariano Rajoy said it was a "jihadist attack" and the nation has declared three days of mourning.
Rajoy tweeted, "The terrorists will never defeat a united people who love freedom against barbarism. All of Spain is with the families and their victims."
Los terroristas nunca derrotarán a un pueblo unido que ama la libertad frente a la barbarie. Toda España está con las víctimas y familias MR— Mariano Rajoy Brey (@marianorajoy) 17 August 2017
Rajoy has also held an emergency meeting in Barcelona to discuss the attack.
U.S. President Donald Trump tweeted, "The United States condemns the terror attack in Barcelona, Spain, and will do whatever is necessary to help. Be tough & strong, we love you!".
The United States condemns the terror attack in Barcelona, Spain, and will do whatever is necessary to help. Be tough & strong, we love you!— Donald J. Trump (@realDonaldTrump) 17 August 2017
The French President Emmanuel Macron voiced "France's solidarity" with Spanish citizens following what he called "a tragic attack".
While Pope Francis's spokesman said in a statement: "The Pope prays for the victims of this attack and wishes to express his closeness to all the Spanish people, especially the wounded and families of the victims"
It was the latest in a series of attacks in Europe in which vehicles have been used to mow down pedestrians in public spaces. More than 100 people have died in similar attacks in Berlin, London and Nice.
Las Ramblas, a busy tree-lined promenade that cuts through the center of Barcelona, is one of the city’s top tourist destinations. People walk down a wide, pedestrian path in the center of the street, but cars can travel on either side.
Barcelona draws at least 11 million visitors a year. In recent weeks, threatening graffiti against tourists has been found in the Spanish city.