Police arrested the Moroccan national in San Pedro del Pinatar in Spain's Murcia region, the interior ministry said in a statement. He was arrested on terror charges after he was found to have been active on websites glorifying terrorism.
The man, identified only as N.B had also allegedly offered up his services to a terrorist group in Syria and planned to go that the war-torn country to fight.
Spain's interior ministry said the man's profile was typical of the newest wave of jihadists as he had acted in a clandestine manner and had gone unnoticed in his community.
The ministry called the man's arrest "of great importance" in terms of "neutralizing a serious threat".
The man's arrest comes days after experts said Spain was seeing a surge in the number of arrest of home-grown terrorists.
The Spanish government says it has arrested dozens of people suspected of links to groups sending fighters to launch attacks with jihadist groups in Syria.