Spanish police and Moroccan security forces "today detained nine members of a terrorist cell... Linked to the terrorist organisation Islamic State", Spain's interior ministry said.
Authorities in various countries have voiced fears about foreign fighters flocking to join the IS organisation, which controls parts of Syria and Iraq.
The nine suspects were seized in Melilla, a Spanish territory on the northern tip of Morocco, and the nearby Moroccan city of Nador, the ministry said in a brief statement.
Moroccan authorities estimate there are between 1,500 and 2,000 Moroccan jihadists fighting in Syria and Iraq. Spain has arrested dozens of suspected extremists in raids this year.
A US-led alliance has launched air strikes against the IS militants in Syria and Iraq.
IS fighters have beheaded a British aid worker, David Haines and two US journalists, and are holding two other Britons, Alan Henning and John Cantlie.