The 26-year-old Moroccan man was arrested in a counter-terror operation on the Spanish island, which is popular with British holidaymakers.
Police said the suspect was arrested on Tuesday at his home in the city of Palma de Mallorca.
A spokesperson for the Spanish interior ministry said the detainee posed “a clear threat to national security” and had used the internet to target young potential Isis recruits online, help send fighters abroad and encourage attacks in Spain and elsewhere in Europe.
He was allegedly in contact with militants living in the so-called Islamic State in Syria, who facilitated the possible arrival of new fighters and provided instruction on terror attacks.
Neighbours insulted the man as he was led away by police in the Son Gotleu district, with some shouting at him to “show your face” as he covered it with a jumper, the Diario de Mallorca newspaper reported.
Spain has detained 19 people with reported connections to Islamist militants since the start of the year, local media reported.
The operation came amid reports that European beaches could be targeted by Isis in terror attacks similar to the hotel massacre in Sousse, Tunisia, last year.
Bild reported that Italian intelligence agencies had warned their German counterparts that militants posing as vendors could carry out atrocities using machine guns and bombs buried in the sand.
The report could not be independently verified.
Travel advice by the UK’s Foreign and Commonwealth Office states that there is a “heightened threat of terrorist attack globally against UK interests and British nationals, from groups or individuals motivated by the conflict in Iraq and Syria”.
Additional reporting by AP
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies