Police said the men were linked to the Barcelona attack, which so-called Islamic State said it had carried out, according to the BBC.
Police are still hunting the man who drove his van into crowds on Las Ramblas in Barcelona on Thursday.
Spanish media have named Moussa Oubakir, 18, as the suspect.
He is the brother of Driss Oubakir, whose documentation was allegedly used to rent the van involved in the attack.
Spanish PM Mariano Rajoy has condemned what he called a “jihadist attack”. He has announced three days of national mourning and a minute’s silence was held at noon (10:00 GMT) on Friday.
A rented van was driven down Las Ramblas, a popular street in the centre of the city on Thursday afternoon, mowing down tourists and locals.
Witnesses said the van deliberately targeted people, weaving from side to side.
The driver of the van, believed to be the sole attacker, fled on foot and is still being hunted by police.
Las Ramblas is a central boulevard that runs 1.2km (0.75 miles) through the centre of Barcelona from the city’s Plaça de Catalunya (Catalonia Square) to the Christopher Columbus monument at the seafront.
A businessman from New Orleans, who was just arriving in a taxi in Las Ramblas, said: “I heard a crowd screaming. It sounded like they were screaming for a movie star.
Citizens of some 24 countries were killed or injured in the Las Ramblas attack, the Catalan government has said.
Spaniard Francisco López Rodríguez, in his 60s, is the first named victim.
One Belgian national has also been confirmed dead.
France’s foreign ministry said on Friday that 26 French nationals were injured, with at least 11 in a serious condition.
A five-year-old Irish boy suffered a broken leg.
Hong Kong, Taiwan and Greece are among those saying their citizens were injured. German, Pakistani, Philippine, Venezuelan, Australian, Romanian, Peruvian, Dutch, Danish, Algerian and Chinese nationals were also among the casualties, officials said.