Police on Wednesday arrested three Moroccans, including a suspected member of the Islamic State group considered to be a clear threat to national security, Spain's Interior Ministry said.

A ministry statement said the suspect had instruction manuals on jihadi suicide and electronic terrorism and was believed to have had internet contact with IS members in Syria and Iraq.

The ministry said he had an extremely dangerous profile similar to those involved in recent attacks in Britain and France and was considered a threat to Spain.

"We have nothing to indicate he was going to attack immediately but it's certain his radicalization was extreme and he had all the training and information to carry out an attack," Interior Minister Juan Ignacio Zoido told Spanish National Television.

The minister said the suspect was indoctrinating and training the other two arrested.

The detainees, aged between 32 and 38 years, lived together in a residential area of Madrid, police said.

Police video showed two of the three being arrested as they came out of a building before dawn wearing motorbike helmets and moments later heavily armed agents entering the building.

The statement said Spanish police have been involved in the arrests of 172 suspected jihadi activists since the country raised its security alert to one step below the maximum in June 2015.