The men, wearing explosive belts, were linked to the first attack, police say, the BBC wrote.
Thirteen people died and dozens were hurt when a van hit crowds in the Las Ramblas area of Barcelona on Thursday. The driver fled and is still at large.
Spain's PM Mariano Rajoy described it a "jihadist attack", which so-called Islamic State said it had carried out.
Mr. Rajoy has announced three days of national mourning and a minute's silence will be held later on Friday.
The authorities are now also 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.
Police chief Josep Lluis Trapero said it appeared the residents at the Alcanar house had been "preparing an explosive device".
In Cambrils, seven people, including a police officer, were wounded when a car was driven into them early on Friday, Catalan emergency services said. One person is in a critical condition.
Spanish media reported that the attackers' vehicle overturned and when the men got out they were quickly fired upon by police.
A series of controlled explosions were then carried out.
Police say the situation in Cambrils - a popular seaside resort to the south-west of Barcelona - is now under control.
Read alsoBarcelona attack leaves at least 13 dead; name of possible attacker revealedMeanwhile, police are continuing to search for the driver of the van used in the Barcelona attack, who fled on foot. He is believed to be the sole attacker there.
Tourists and locals fled when the rented vehicle sped down Las Ramblas in the center of the city, mowing down people.
Witnesses said the van deliberately targeted people, weaving from side to side as it drove down the boulevard.
Two people have been arrested, but police say neither was the driver.
Police have released a photo of a man named as Driss Oubakir, whose documents were used to rent the van involved in the attack.
Local media say he is in his 20s and was born in Morocco. However, latest reports suggest he has told police he was not involved, and that his documents were stolen.
So-called Islamic State 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". The group gave no further evidence or details to back this claim.
Vehicles have been used to ram into crowds in a series of attacks across Europe since July last year.
In another incident, police shot dead a man who drove into officers at a checkpoint on the outskirts of Barcelona, but the authorities said there was no evidence that he was connected to the attack in Las Ramblas.