A Spanish judge has ordered a Moroccan man who lived on the Mediterranean island of Mallorca to be held without bail after concluding he was prepared to launch a terrorist attack.

Judge Carmen Lamela Diaz said in court documents that the man’s plans for an attack on an unspecified target in Spain had not been carried out for reasons beyond his control. She did not provide more details.

The 35-year-old worked as a cook at a restaurant in the popular tourist destination of Palma de Mallorca. He was arrested on Tuesday.

The court documents said he had tried to recruit Islamic State combatants and had been in contact with leaders of the extremist group in Syria.

Police reported finding cocaine and scales in his apartment.