The attackers were wearing explosive belts, police said.
Thirteen people died and dozens were injured when a van ploughed into crowds in Barcelona's Las Ramblas area on Thursday afternoon. The driver of the van fled and is still at large.
Spain's Prime Minister Mariano Rajoy said it was a "jihadist attack".
The 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.