An Interior Ministry statement today said the man of Moroccan origin is serving a sentence for domestic violence but is considered an Islamic radical.
It said he is under investigation for recruiting inmates whose sentences were about to finish in the prison outside the central city of Segovia.
The statement said he also made unspecified threats in the name of Islamic State leader Abu Bakr al-Baghdadi.
The ministry said the arrest was part of moves to clamp down on the radicalization of prisoners.