Spanish Interior Minister Jose Antonio Alonso said police broke up two cells, one based in Madrid and the other in the Catalonia town of Vilanova i la Geltru, near Barcelona.
Police made 16 predawn arrests in Vilanova i la Geltru, which included an imam from a local mosque, Spanish national radio reported.
Three arrests were made in Madrid and one in Lasarte in the Basque region.
Fifteen of the detainees were Moroccan, three were Spaniards, one was Turkish and another Algerian, the interior minister said.
Mr Alonso said the two cells in Spain had links to people in France, Belgium, the Netherlands, Algeria, Morocco, Turkey, Syria and Iraq.
Spanish television showed police carting away large containers of documents and other material to sift through as part of their investigations into the suspects' activities.
Iraq connection
Mr Alonso said the cell based in Vilanova i la Geltru broken up on Tuesday may have started sending fighters to Iraq around late 2003, but he did not specify how many people it sent.
The cell is suspected of being connected to a suicide attack on an Italian base in the Iraqi town of Nasiriya on November 2003, which killed 18 Italian military police, he said.
Last month Spanish authorities arrested 16 people suspected of recruiting fighters to carry out attacks in Iraq, Chechnya and Kashmir, while two other suspects surrendered.
Six of them were jailed and 12 others set free after having their passports confiscated.
Judicial authorities believe one of the six still in police detention was a direct contact of Jordanian-born extremist and top al-Qaeda operative in Iraq, Abu Musab al-Zarqawi.
In mid-2004, a Moroccan sent to Iraq by one of the Spanish cells was arrested in Syria and sent back to Morocco, apparently after fighting in the Iraqi city of Fallujah under the command of Zarqawi, the minister said.
Meanwhile, about 40 people suspected of involvement in the 2004 train bombings in Madrid are expected to go on trial later this year, according to Spanish judicial sources.
The blasts targeting commuter trains and stations, claimed by al-Qaeda, killed 191 people and injured about 1,900 in Spain's worst-ever terrorist attack.
