Three Moroccan nationals suspected of being affiliated with ISIS were arrested during early morning raids on Tuesday in Madrid and Rivas-Vaciamadrid, Spanish police said.

Authorities said they acted quickly to detain the three suspects, aged between 26 and 29, due to suspicions that the three were preparing to carry out an attack in Spain similar to recent attacks that have occurred elsewhere in Europe, according to The New York Times

"The terrorists were extremely radicalized and had assumed terrorist discipline and ideology completely," national police said in a statement released by Spain's interior ministry. "They were perfectly organized and [worked within a] hierarchy and each one of the components had a determined role."

When it was broken up, the trio were "fully radicalized and in a phase of total assimilation and commitment to the terrorist ideology - demonstrating their full disposition to carry out an attack in Madrid,"  the statement continued, adding that the group was primarily using the Internet and social media to spread its message, according to CNN.

The statement added that the leader of the cell recruited others by spreading ISIS doctrine and "terrorist discipline," while the other two were "operatives" tasked with carrying out terrorist acts.

The three men are currently in custody and being interrogated, an Interior Ministry spokesman said. Authorities can hold them for up to five days before pressing charges.

In addition to threats from a Basque separatist group known as the ETA, Spain has had to contend with a number of terror cells in recent years, reported NBC News. Two notable ones include one linked to January's Charlie Hebdo attacks in Paris, and another convicted of its role in the 2004 Madrid station bombing that killed 191 people.