Police have so far launched 12 raids in the Spanish capital, detaining eight people, and the investigation remains open, Spain's interior ministry said in a statement.
The recruitment cell found and dispatched recruits for the terrorist group of so-called Islamic State of Iraq and the Levant (ISIL) militants based in Syria and Iraq, the ministry said.
ISIL terrorists made rapid military gains in Iraq last week, seizing the second-biggest city Mosul and coming within 80 kilometers (50 miles) of Baghdad.
Online photos show ISIL terrorists massacring captured Iraqi people during the offensive.
"It should be highlighted that the leader of this cell lived in Spain after passing through the Guantanamo military base, having been arrested in Afghanistan in 2001," the Spanish ministry said, without elaborating.
Spain's press said the arrested ringleader was Lahcen Ikassriem, a Moroccan who was held for three years in the US prison camp at Guantanamo Bay.
The suspect was reportedly extradited in 2005 to Spain where he was held in preventative detention for more than a year before being freed by the Spanish courts in 2006.
The interior ministry was not immediately available to confirm these details.
NJF/NJF