One of the Madrid suspects is taken into custody. EFE

The other two shared an apartment with the former, who was training them to join ISIS, said the ministry in its release.

The raid took place in the early hours of Wednesday, just two days before the Spanish capital is due to play host to World Pride 2017. Madrid has boosted security measures to deal with an event that is expected to attract around two million people to the Spanish capital between June 23 and July 2.

The main suspect’s profile is said to coincide with the background of “terrorists recently involved in the attacks in Britain and France”

The raid also comes just hours after soldiers in Brussels shot and killed a suspect who had detonated a small explosive device at the city’s Central Station.

The main suspect held in Madrid is a 32-year-old Moroccan national accused of having links to ISIS.

His profile is said to coincide with the background of “terrorists recently involved in the attacks in Britain and France.” He is being considered “a clear threat to security” in Spain, according to the ministry release.

He was allegedly training his roommates, two Moroccan nationals aged 33 and 38, to carry out violent acts in Spain.

The Interior Ministry said that the seized material included handbooks on how to become a suicide bomber and another one on how to wage jihad online. Spain’s National Police force is currently analyzing these documents, whose contents range from “the most radical kind of ideological prepping” to “acts of martyrdom.”

Spain has been on a threat level 4 (level 5 is the highest) for the terrorist threat since June 26, 2015 when attacks were carried out in countries including France, Tunisia and Kuwait, among others. Since then, law enforcement agencies have arrested 172 jihadists in Spain and abroad.