UPDATE: The man suspected of driving the van has now been named as 22-year-old Moroccan national, Younes Abouyaaqoub, who is thought to be on the run.
The key suspect in the Barcelona attack was among the five people shot dead by police at the scene of a second deadly incident, they have confirmed.
Spanish officials also warned the back-to-back vehicle attacks in Barcelona and a nearby resort were planned for a long time by an Islamic terrorist cell - and could have been far deadlier had its base not been destroyed by an apparently accidental explosion this week.
Moussa Oukabir is believed to have driven the van that crashed into people on Las Ramblas, the bustling tourist hotspot in Barcelona, killing 13 and injuring more than 100.
He was among five people shot dead by police in the resort town of Cambrils in the early hours of Friday, after they crashed their car into a group of people, killing one woman.
police confirmed to Spanish TV station TV3.cat that two other suspects they were seeking - Said Aallaa and Mohamed Mychami - were also killed in the exchange.
All this followed an explosion at a house in Alcanar, which may have been a bomb factory, on Wednesday. One woman died in that explosion.
At a Friday press conference, Catalan police official Josep Lluis Trapero said the terror cell was preparing a bigger attack but the explosion cost them the material they wanted to use.
He said: “We think they [the suspects in Alcanar] were preparing at least one or more attacks in Barcelona.
“The explosion took out some of the material they were counting on to carrying out even bigger attacks than the ones that happened.
“Because of that the attacks were carried out in a more rudimentary way than the one initially planned.
“Alcanar was the site of an explosion in a house shortly before midnight on Wednesday, in an incident which police are now linking to the attacks.”
Police intensified their manhunt for a number of suspects still on the loose Friday, releasing details of four men.
Oukabir, 17, was the younger brother of one of the men arrested on Thursday.
Citing police sources, Spanish media including newspaper Eli Pais, RTVE and TV3, named Moussa Oukabir as the suspected driver of the van.
Very little is known about Oukabir, but a great deal of attention has focussed on comments believed to have been made by the teen on social media.
Asked on the website Kiwi what he would do if he was leader of the world for the day, Oukabir responded: “Kill the infidels I just let Muslims follow the religion”.
In another post, when asked which country he would never live in, Oukabir replied: “In the Vatican”.
Police said that of the four men they were looking for, only one was unaccounted for.
The other three suspects, besides Oukabir, are Mohamed Hychami, 24, Younes Abouyaaqoub, 22, and Said Aallaa, 18.
Abouyaaqoub remains unaccounted for, police said, adding that Hycham and Aallaa were also dead.
A judicial source said investigators believed a cell of at least eight people, possibly 12, may have been involved in the Barcelona and Cambrils operations and that it had been planning to use gas canisters.
“We are not talking about a group of one or two people, but rather a numerous group,” regional Interior Ministry chief Joaquim Forn told Onda Cero radio.
Police said they arrested two more people Friday, after an initial two were arrested Thursday - three Moroccans and one Spaniard. Three of them were arrested in the northern town of Ripoll. Another arrest was made in Alcanar.
They were aged between 21 and 34, and none had a history of terrorism-related activities.
Elsewhere riot police have dispersed a small group of far-right protesters after separating them from hundreds of counter-protesters near the site of a memorial to the Barcelona van attack victims.
The far-right protesters, numbering 20-30, held up signs saying “Stop Islamisation of Europe.” Counter-protesters were chanting “tontos,” or “idiots” at them, with some of them holding up their middle fingers at the far-right protesters.
Riot police wearing helmets with face shields kept them apart for a while before gently removing the far-right protesters. After they walked away, the counter-protesters applauded and also left peacefully.
The protest came a day after a van rammed into pedestrians in Barcelona’s Las Ramblas district, killing 13 and injuring 120.