The man, who lives in Spain, was detained in the eastern town of Castellon, Interior Minister Juan Ignacio Zoido said in a Twitter message without providing further details.
In August a group of jihadists, many of them of Moroccan origin, killed 16 people in two attacks using vehicles and knives in Barcelona and the seaside resort of Cambrils in northeastern Spain.
The main suspects in the attacks, claimed by the Islamic State group, were of Moroccan origin, but most had lived in Spain for several years.
Police shot dead six of the suspected members of the cell that carried out the attacks and arrested another four. Two other suspects died in an explosion at a house used by the plotters at Alcanar, southwest of Barcelona.