Five of those detained on Wednesday are Moroccan and one is a Spaniard of Moroccan origin, Spain’s Interior Ministry said.
The alleged leader of the cell, a 39 year-old Moroccan, lived in Melilla, a Spanish enclave in northern Africa, but was arrested while visiting the neighboring country. He allegedly recruited youngsters at a reeducation center where he worked and used Islamic State group propaganda to train them, the ministry said in a statement.
Violent attacks in August claimed by IS killed 16 people in and near Barcelona.
Since mid-2015, Spain has arrested 199 people accused of links to extremism.