The pair pledged allegiance to Daesh and its leader Abu Bakr al-Baghdadi, the ministry said in a statement, using an alternative name for the Islamic State group.
They also "launched death threats in the name of Daesh against Spain and France, as well as against other religious groups."
Spain holds three suspected Islamic State recruiters
The suspects are of Moroccan nationality and lived in Spain legally, the ministry said. The arrests took place in the northern city of Mataro and on one of Spain's Canary Islands off the coast of Africa.
The suspects allegedly helped in recruitment, indoctrination and enrolment of new recruits, were in "constant contact with active members in Syria" and distributed multimedia material to teach new recruits how to use arms and explosives.
Like other European nations, Spain has been grappling with a growing number of militant cells on its territory and radicalised Muslims leaving to fight for Islamic State or other militant groups in Iraq and Syria.
British Muslim woman goes undercover to document Islamic State recruiting techniques
This operation brings the number of suspected militants arrested since the beginning of the year to 100, the ministry said.
Spain raised its terror alert to four on a scale of five on June 26 following deadly attacks in France, Tunisia and Kuwait.
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