Spanish police on Friday said that they killed five people in the town of Cambrils to stop a second attempted van attack after an earlier one in Barcelona that claimed the lives of 13 people and injured over 100 others.
In Cambrils, seven people including a police officer were injured when a car rammed into a group earlier on Friday, the BBC quoted the Catalan emergency services as saying.
Spanish media reported that the vehicle overturned and when the attackers, who were wearing explosive belts, got out they were quickly fired upon by police.
The police have said that the situation in Cambrils - a popular seaside resort - is now under control.
A bomb squad is deployed to carry out controlled blasts on the explosive belts.
The incident in Cambrils came after Thursday afternoon's attack in Barcelona when a van ploughed into crowds in the city's Las Ramblas area.
The driver of the van, who fled on foot, is still at large.
The Islamic State terror group has said it was behind the Las Ramblas attack, saying in a brief statement carried by its Amaq news agency that it was carried out by "Islamic State soldiers".
Authorities are now linking the attacks in Barcelona and Cambrils with an explosion at a house on Wednesday evening in the town of Alcanar that left one person dead.
So far, two people have been arrested, and the police have released a photo of a man named as Driss Oubakir, whose documents were used to rent the van involved in the attack, reports the BBC.
However, latest reports suggest the 20-year-old Moroccan born has told the police that he was not involved and his documents were stolen.
The people injured in the Las Ramblas attack included four Australians and one from Hong Kong, reports CNN.
Belgium has confirmed that one of its citizens was among the 13 victims.
Spain's Prime Minister Mariano Rajoy has travelled to Barcelona and declared three days of national mourning.
He said the attack was "jihadi terrorism".
"I want to express my solidarity with all of Spain to the city of Barcelona, today hit by jihadi terrorism, like other cities have been in the world."
The One World Trade Centre in New York lit up in the colours of the Spanish flag to show solidarity with Barcelona. In Paris, the Eiffel Tower went dark
In a statement, US President Donald Trump said: "The United States condemns the terror attack in Barcelona, Spain, and will do whatever is necessary to help. Be tough and strong, we love you!"
Russian President Vladimir Putin said the attack in Barcelona was a "cruel and cynical crime committed against civilians".
Facebook has activated its safety check mechanism, allowing users both in Barcelona and Cambril to mark themselves as safe.