A prisoner exchange enabled three European aid workers held hostage to be released on Wednesday in Mali, negotiators have revealed.
"It was a release in exchange for a release," said Gen Gilbert Diendere, who headed the mediation team, according to Reuters news agency.
He said two Islamists had been freed in Mauritania but did not confirm their identities.
The two Spaniards and an Italian have flown home from Burkina Faso.
"I thank the Burkina government for the liberation," Spaniard Enric Gonyalons told reporters at a base in Ouagadougou. "Liberation for liberation."
He was held along with fellow Spaniard Ainhoa Fernandez and Italian Rossella Urru since last October - seized from the Rabuni refugee camp near Tindouf in western Algeria.
Italian Prime Minister Mario Monti was among those welcoming Ms Urru as she arrived at Rome airport.
She acknowledged that international aid work was dangerous, but added: "This will not stop me."
They were held by the previously unknown Movement for Oneness and Jihad (Mujao), which says it is an offshoot of al-Qaeda in the Islamic Maghreb (AQIM).
The group says it received a ransom of 15m euros (£12m; $18m) for their release, according to the Agence France-Presse news agency.
Negotiators say they cannot confirm any ransom was paid, but a ransom and the release of two men arrested by Mauritania for their alleged role in the kidnapping were among the demands made by Mujao for the release of the hostages in May, AFP says.
According to Gen Diendere, one of the two Islamists exchanged for the aid workers has already been returned to Mali from Mauritania.
Mauritanian media reports named one of those freed as Memine Ould Oufkir, who was arrested in the wake of the kidnapping.
A Tuareg rebellion in northern Mali triggered a military coup in March and in the ensuing chaos Islamist groups seized control of several towns in the north.
The trio of aid workers were released from captivity in the Malian region of Gao, said to be controlled by Mujao.
Several European and South African nationals remain in the hands of kidnappers in the region.