Officials at Baghdad International Airport became suspicious earlier this month when their X-ray machines could not see into 23 large bags unloaded from a Qatari plane, producing only a black image because the contents were wrapped in a special material impenetrable to detecting devices. They were further amazed when they opened the bags to discover that they contained hundreds of millions of dollars and euros in cash worth a total of $500m (£389m), says an Iraqi source.

It is now clear that the money was ransom for 24 Qataris, several of them leading members of the Qatari royal al-Thani family, and two Saudis who had been hunting with falcons with official permission in supposedly safe southern Iraq when they were kidnapped 16 months ago by a Shia militia task force. A deal to get them released has been complicated by negotiations involving Qatar and Iran as well as Shia and Sunni militias over the simultaneous evacuation of people long besieged in four towns, two Shia and two Sunni, in northern and southern Syria respectively.

The extraordinary story of the $500m ransom – perhaps the biggest ransom ever in history – and the release of the Qatari royalty is revealed in a confidential document sent by Iraqi Prime Minister Haider al-Abadi and obtained exclusively by The Independent. In a special report dated 22 April, six days after the episode at the airport, he gives senior members of his ruling Dawa Party a detail account of actions by his government, Qatar and other players inside and outside Iraq though the precise identity of several is left vague.

Mr Abadi says that Qatar had requested the Iraqi government for permission to land an aircraft at Baghdad International Airport on 15 April on the understanding that it would take on board freed members of the kidnapped hunting party. But he says the airport officials were “surprised that there were 23 large heavy bags that appeared without prior notice or approval”. When these were put in the X-ray machine “the image appeared black”, which meant that whatever was inside was wrapped in a special impenetrable material.

Those on board the plane included the Qatari ambassador to Iraq and a special envoy from the Qatari Emir Tamim bin Hamad al-Thani, but they had not asked for the bags to be given diplomatic immunity. They apparently had not done so because they believed that the kidnappers or their emissaries had their own people at the airport who would take charge of the money.

Mr Abadi says that even before opening the bags Iraqi officials had become convinced, through overhearing the conversation of the Qataris, that they contained money. What they did not know was how much, so when they finally searched them and counted the cash they were astonished to discover that the amount totalled “hundreds of millions of dollars and euros”. By then the Iraqi government had been told, presumably by the Qataris, that the cash was a ransom payment. But its officials still confiscated it since their government had not been informed about what was going on and they were chary of seeing such a large sum paid to a militia that would inevitably be empowered by a massive cash injection. “Hundreds of millions for armed groups? Is this acceptable?” Mr Abadi asked later at a press conference.

The militia widely reported to have carried out the original kidnapping of the hunting party in Iraq’s southern Muthanna proince in December 2015 was the powerful Iranian-supported movement known as Ketaeb Hezbollah, which is distinct from Lebanese Hezbollah. But all Iraqi and Syrian militias both Shia and Sunni have links, often undeclared and unprovable but well known to most Iraqis and Syrians, to local politicians, political parties and foreign states. Sometimes, the militias are simple proxies of others but usually the relationship is more complex with a degree of mutual dependence.

Mr Abadi hints at this when he mentions in his report that, as news of the confiscation of the money at the airport spread in Baghdad, “third parties intervened strongly, some from the highest levels” and others threatened to use armed force. The Qatari envoy and the Qatari ambassador who had arrived on the plane had a bitter dispute over what had gone wrong. What is not clear is why the kidnappers released their hostages on 21 April, though they had not yet received the ransom, unless they were confident that once it was in Baghdad airport it was as good as in their hands or replacement funds had been sent by Qatar. Mr Abadi says that the Qataris had been led to believe that “the sponsors of the kidnappers” had effective control of the airport and of the security forces there.

A second strong reason for the freeing of the hostages going ahead is that their release was part of a regional deal involving Qatar, Iran, Jabhat al-Nusra, formerly the al-Qaeda representative in Syria, as well as various Shia militias. This relates to the fate of two Shia towns, Fua and Kefraya, with a combined population of 40,000, that have long been under siege by Sunni Arab militia forces including al-Nusra in Idlib province in northern Syria, and two Sunni towns, Madaya and Zabadani west of Damascus, that are besieged by pro-Syrian government forces including Lebanese Hezbollah. Under an agreement all four towns were to see simultaneous and linked evacuations as a result of stop-go negotiations that have been going on for several years. On the day of the hunters’ release last Friday, an Iraqi source told AFP “the Qataris are now in Haider al-Abadi’s office following a deal between Jabhat al-Nusra and the kidnappers.”

ORDER IT NOW

The release of the hostages had earlier been stalled when busses carrying Shia evacuees from Fua and Kefraya were attacked on 15 April by a suicide bomber in a vehicle, which exploded, killing 126 people, including 68 children and wounding a further 300. This was the same day that the Qatari plane landed in Baghdad. Given that all militias in Syria and Iraq are highly criminalised, the money would presumably have to be shared out among all of those involved as well as with some of their outside sponsors.

Mr Abadi is clearly angry at the way in which Iraq has been caught up in the complicated manoeuvres of foreign powers like Qatar, Iran, Lebanese Hezbollah and a variety of Iraqi and Syrian private armies. He says that “allowing [the Qataris] to deliver big money to armed groups in Iraq, and perhaps also to terrorist groups is to fuel the war.”

The affair has not ended since the Iraqi government now has half a billion dollars whom very violent paramilitary groups and their sponsors were expecting to be paid to them. These are often described as militias, though in fact they are heavily-equipped private armies who pose as community defenders, but are frequently guns-for-hire for foreign states and for their own enrichment. They will not resign themselves easily to the loss of the contents of the 23 bags confiscated at Baghdad airport.