Spain on Tuesday arrested two men, one of Algerian origin and the other of Moroccan origin, it said had links to Al-Qaeda militants in Mali.
The interior ministry said the two had a "similar profile" to the suspects in the Boston bombings -- though a judicial official said they had no proven ties to the US attacks.
The men, apprehended in different parts of the country, were "suspected members of a radical cell related to the terrorist organisation AQIM," Al-Qaeda in the Islamic Maghreb (AQIM), which has carried out attacks and kidnappings across north Africa, the ministry said.
The ministry said the Algerian man, identified as Nou Mediouni, and the Moroccan man, Hassan El Jaaouani, had "profiles" like those of the two ethnic Chechens living in the United States who are suspected of carrying out the deadly bombings last week at the Boston Marathon.
A judicial source who declined to be named stressed, however, that the two arrested had no known concrete links to the US bombings.
The interior ministry said Mediouni was arrested in Spain's northern city of Zaragoza and Jaaouani was arrested in the southeastern region of Murcia after a year-long operation with the help of French and Moroccan police.
The ministry said Mediouni was highly radicalised and was believed to have been recruited by Mali-based AQIM members via an online militant forum.
The network instructed him to travel to a "jihadi training camp" run by AQIM in northern Mali.
His trip fell through when he was prevented from contacting AQIM due to security measures in Mali, where French and African forces have driven Islamist militants from their strongholds over recent months.
Mediouni returned to Spain "highly frustrated at not having been able to 'die like a martyr' as he had wished," the ministry said.
It said El Jaaouani meanwhile had also been in contact with Mali-based AQIM leaders, one of whom was "directly linked" with the kidnapping and killing of two French nationals in Niger in 2011.
The ministry said the Mali-based militants "carried out the recruitment of the candidates with the most radical profiles, directing them gradually towards more and more private online forums with strict security measures".
A judicial source who asked not to be named said the two suspects would go before a judge at the National Court in Madrid on Thursday.
Police were searching the suspects' homes, the ministry said.
It said 13 people had been arrested in Spain for "international terrorism" since the current conservative government took office at the end of 2011.
Police in February arrested a 22-year-old Moroccan, Mohamed Echaabi, in Valencia for allegedly plotting terrorist attacks in Spain and elsewhere in Europe.
In August, they arrested two Chechens and a Turk, suspected Al-Qaeda members thought to have been planning an attack in Spain or elsewhere in Europe.
On March 11, 2004, Spain suffered one of Europe's worst terror attacks when explosions linked to Al-Qaeda killed 191 people on packed commuter trains in Madrid.
Twenty-one people, mostly Moroccans, were convicted of involvement in those attacks.