"This brings an end to an act of terrorism that should never have happened."

Alicia Gamez, a third hostage who worked with the men for Accio Solidaria, a Catalan charity, was set free in March.

Spain's daily newspapers El Mundo and ABC both reported on Monday that the release of the aid workers was the result of a payment by the Spanish government which El Mundo put at $4.8m and ABC at between $6.3m and $12.7m.

The Spanish government strongly denied that a ransom had been paid following the release of Gamez but has been silent on the reports of ransom payments since then.

'Demands met'

AQIM issued a statement saying "thanks to God, the mujahedeen have found a positive solution to the issue of the Spanish hostages Albert Vilalta and Roque Pascual, which ended on Sunday ... with their release after some of our demands were met," without specifying what these demands were.

Their release follows the transfer from Mauritania to Mali of the kidnap mastermind, Malian national Omar Sid'Ahmed Ould Hamma, who had been jailed for 12 years by a Mauritanian court. 

But officials in Mauritania and Mali have not confirmed whether the two events are linked.

AQIM said the release was a "lesson for the French secret services to take into consideration in the future," referring to failed Mauritanian-French raid in Mali in July that aimed to rescue French hostage Michel Germaneau  and in which seven AQIM members were killed.

"They had the chance to act responsibly and use their heads with the mujahedeen and avoid the madness and anger that led to the deaths of their citizens."

AQIM has said that Spain is one of its targets because it is an ally of the United States and part of the Nato military alliance.