Suspects were detained in the outskirts of Madrid and in other cities and towns in Morocco, it added.
The arrests were linked to "a network ... capturing and sending foreign fighters to join the ranks of the terrorist organisation Daesh (Islamic State) in the Syrian-Iraq region that it controls," the ministry statement said.
The operation comes days after a 26-year-old Moroccan man was accused of attacking passengers on a train in France, armed with a Kalashnikov, an assault rifle and a box cutter knife.
Spain and other countries in Europe and north Africa have said they are alarmed about the risk of locals joining militants abroad and returning to launch attacks at home.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ