The Moroccan national, who lives in Spain, was detained on Tuesday in Stuttgart in southwestern Germany, the ministry said in a statement.
A Spanish court had issued a warrant for his arrest.
The ministry said he was “very active on social networking sites, playing the role of recruiter by touting the benefits of joining (Islamic State) fighters”.
— Ministerio Interior (@interiorgob) August 4, 2015
In early July, he had expressed his intention to fight along Islamic State extremists in Syria and invited his followers on social networks to join him.
He escaped police raids on the island of Lanzarote on Spain's Canary Islands, in which a woman was arrested on suspicion of recruiting young women and teenagers for travel to Syria.
Spain has been cracking down on suspected jihadists in recent months.
Scores of suspects have been arrested, mostly in the enclaves of Melilla and Ceuta, on the north coast of Africa, and in the northeastern Catalonia region.
The government says at least 116 Spaniards have left to join jihadist groups in Syria and Iraq, as of July 5, a relatively low number compared to other European nations such as France and Britain, which have seen hundreds of citizens travel to the Middle East to wage jihad.
European governments fears that combattants could return to mount attacks on home soil.
Spain's interior ministry in June raised its terror alert level from three to four, with five being the highest on the scale.