At least 13 people were killed and 100 injured after a suspect ploughed a white van into a crowd at around 5pm local time (15:00 GMT) on Thursday in the bustling Las Ramblas area, a 1.2-kilometre stretch of shops and restaurants usually heaving with tourists.
Spanish police said the suspected driver was still on the run and that they had arrested two other people in connection with the attack. Police cordons had been set up around the city.
“The executors of the Barcelona attack were soldiers of the Islamic State,” ISIL’s Amaq outlet said on its Telegram messenger account, without naming those it claimed were behind the attack.
Amaq said ISIL had launched the attack in response to calls to target states taking part in the United States-led coalition battling the group in Iraq and Syria.
ISIL has claimed several similar attacks in Europe over the past year.
Police described Thursday’s violence as a “terrorist attack”.
El Pais newspaper said the driver of the vehicle had fled on foot after the attack.
It was still unclear how many attackers had been involved in the incident.
Catalan police said on Friday they had killed the perpetrators of a “terrorist attack” in the town of Cambrils, south of Barcelona, following a police operation.
Spain’s public broadcaster, RTVE, reported that regional police troopers killed four people and injured another. It was not clear if the operation was connected to Thursday’s van attack.
Catalan emergency services said on Twitter that people in Cambrils should “stay home, stay safe”.
The Thursday van attack in the northeastern Catalan city was the country’s deadliest since 2004 when al-Qaeda-inspired bombers killed 192 people in coordinated attacks on Madrid’s commuter trains.
Joaquim Forn, Catalonia’s interior minister, confirmed the death toll on Twitter.
There were fears the death toll could rise given the severity of some injuries.
At least one Belgian national – a woman – was among those killed, the country’s Foreign Minister Didier Reynders said on Twitter.
There were at least 18 nationalities among the victims who came from countries as varied as France, Venezuela, Australia, Ireland, Peru, Algeria and China, according to Spain’s civil protection agency.
Catalan police chief Josep Luis Trapero said that an explosion which killed one person and destroyed a house in the town of Alcanar, 200km south of Barcelona, on Wednesday night, was “clearly” linked to the attack.
Residents of the house were preparing explosives using gas cylinders, a Catalan police source told Reuters news agency.
However, Trapero said that so far there was no evidence that another incident, in which police shot dead a man after he tried to evade a checkpoint while leaving Barcelona hours after the attack, was connected.
‘It was brutal’
People have been warned against travelling to Placa Catalunya.
Nafees Hamid, a witness, told Al Jazeera: “There are helicopters everywhere above, and armed police are rushing into the area. Police have cordoned off Las Ramblas.”
He explained by phone that most people heeded a police warning to go inside while the situation was active.
Another witness told Al Jazeera he heard a lot of people screaming, then he saw the van going down the boulevard.
“You could see the bodies lying all through Las Ramblas. It was brutal. It was a very tough sight,” he said.
Witness Aamer Anwar told Britain’s Sky News television that he was walking down Las Ramblas, which he described as “jam-packed” with tourists.
“All of a sudden, I just sort of heard a crashing noise and the whole street just started to run, screaming. I saw a woman right next to me screaming for her kids.”
Spanish Prime Minister Mariano Rajoy rushed to the city and announced three days of mourning, calling the killings a “savage terrorist attack” and said Spaniards “are not just united in mourning, but especially in the firm determination to beat those who want to rob us of our values and our way of life”.
Emergency services asked metro and train stations to close, according to reports.
The alleged attack took place at the height of the tourist season in Barcelona, which is one of Europe’s top travel destinations with at least 11 million visitors a year.
Meanwhile, a second van linked to the attack was found in the small town of Vic in Catalonia, local authorities there said on Twitter.
Catalan police also said a driver earlier hit two officers in Barcelona, but it was unclear whether this incident was related to the early evening attack in Las Ramblas.
James Glancy, a defence and security consultant, told Al Jazeera that the Las Ramblas attack bears the hallmarks of ISIL-inspired attacks.
“What they are trying to do is coordinate and prolong the attack to maximise their media attention and therefore appeal to a recruitment base and improve their funding,” he said.
Glancy said that if confirmed, it would be the first ISIL attack on Spanish soil.
“There is also definite coordination across Europe from different cells of ISIL,” he said. “This is a planned attack, and it’s had the effect that they wanted in order to get the media there and create hysteria and fear within Spain.”
Diego Muro, a lecturer in International Relations at the University of St Andrews, told Al Jazeera that although ISIL had claimed responsibility, the group may not have directly organised or masterminded the attack.
“It is also possible that the attack has [just] been inspired by [ISIL]. Both possibilities should be on the table,” said Muro.
Muro said that while Spanish security forces are well respected, their resources are limited and the number of “radicalised” people is growing.
“Attacks such as these are reliant on very little technology and very little logistics,” he said.
Russian President Vladimir Putin was among those who expressed his solidarity, calling for the world to unite in an “uncompromising battle against the forces of terror”, the Kremlin said.
“What happened once again confirms the need for a genuine unification of efforts by the entire world community in an uncompromising battle with the forces of terror,” Putin said in a telegram of condolences to Spanish King Felipe VI, describing the incident as a “cruel and cynical crime”.
Secretary of State Rex Tillerson sent condolences and offered US assistance to Spanish authorities.
French President Macron expressed France’s solidarity after what he termed a “tragic attack”.
German Chancellor Angela Merkel described the incident as “a revolting attack”.
British Prime Minister Theresa May condemned the “terrible” attack and said the UK “stands with Spain against terror”.
European Commission President Jean-Claude Juncker expressed his “profound sorrow and anguish”.
Pope Francis said he was praying for the victims.
While full details of the incident were not immediately clear, since July 2016 vehicles have been used to ram into crowds in a series of attacks across Europe, killing more than 100 people.
Al Jazeera’s Tyson Shine, reporting from Barcelona, said the attack was a “grim reminder of an ever-increasing list of similar attacks”.
“Nice, London, Brussels, Berlin, and Stockholm – now Barcelona. An everyday vehicle once again used as a deadly weapon,” he said.