Qatar has secured the release of 26 hostages after nearly a year and a half in captivity, including members of its ruling family, in what became possibly the region's most complex and sensitive hostage negotiation deal in recent years.

Several people with knowledge of the talks and a person involved in the negotiations said the hostage deal was linked to one of the largest population transfers in Syria's six-year-long civil war, and was delayed for several days due to an explosion one week ago that killed at least 130 people, most of them children and government supporters, waiting to be transferred.

The transfer of thousands of Syrian civilians was also tied to another deal involving 750 political prisoners to be released by the Syrian government.

The complexity of the talks highlights Qatar's role as an experienced and shrewd facilitator in hostage negotiations -- this time involving members of the Gulf Arab state's ruling family.

It also raised allegations that the tiny energy rich nation paid millions of dollars to an al-Qaida-linked group to facilitate the population transfer in Syria that led to the hostages' release in Iraq on Friday.

Qatar is home to Centcom's regional headquarters and is where the U.S. has its largest military base in the Middle East. It is also a member of the U.S.-led coalition fighting the Islamic State group in Iraq and Syria.

The incident was sparked when the group was kidnapped Dec. 16, 2015 from a desert camp for falcon hunters in southern Iraq. They had legally entered Iraq to hunt inside Muthanna province, some 230 miles southeast of the Iraqi capital, Baghdad. Shiite militias are active in that area and work closely with the neighboring Shiite power Iran.

A person involved in the negotiations told the AP that 11 of the captives were members of Qatar's Al Thani ruling family. He also said Qatar paid tens of millions of dollars to Shiite groups, and to the al-Qaida-linked Levant Liberation Committee and Ahrar al-Sham, which are involved in the population transfers underway in Syria. Both groups were part of an armed opposition alliance that swept through Syria's Idlib province, seizing it from government control in 2015 and laying siege to two pro-government villages now being evacuated.

Speaking on condition of anonymity due to the sensitivity of the situation, the negotiator said the Qatari group was being held by Iraqi Shiite militia Kata'eb Hezbollah. The group officially denies it was behind the kidnapping and no other group has publicly claimed responsibility for the abduction.

He said Qatari officials were given assurances about the well-being of the hostages during negotiations.

Two Iraqi officials-- a government and a security official -- also confirmed details of the release to the AP.

The abduction of the Qatari group drew Iran, Qatar and the Lebanese Shiite militant group Hezbollah into negotiations, resulting in millions of dollars in payments to Sunni and Shiite factions, according to Iraqi officials and a person involved in the negotiations. They say the talks took place in Beirut.

The negotiator said the ongoing evacuation and transfer of thousands of Syrians from four besieged areas was central to the release of the Qataris. The two pro-government villages, Foua and Kfarya, had been besieged by rebel fighters and under a steady barrage of rockets and mortars for years. The two opposition-held towns, Zabadani and Madaya, were under government siege for joining the 2011 uprising against Syrian President Bashar Assad.

The opposition-run Britain-based Syrian Observatory for Human Rights, which monitors the Syrian conflict through a network of on-the-ground activists, says the transfer included 800 armed men from both sides. Rami Abdurrahman, who heads the group, told the AP that the population swap in Syria was directly tied to the issue of the kidnapped Qataris.

Abdurrahman, citing information from negotiators he'd spoken with, said the Qataris first proposed bringing the fate of the hunting group into the talks about the besieged four areas in Syria.

The population exchange has been criticized by rights groups, which say it rewards siege tactics and amounts to forcible displacement along sectarian lines.

Iraqi Interior Ministry official Wahhab al-Taie told The Associated Press the hostages had been released into the custody of the Iraqi Interior Ministry. The group departed Friday afternoon on a private Qatari jet from Baghdad.

Qatar's state TV showed the arrival of the group from Iraq as ruler Sheikh Tamim bin Hamad Al Thani waited to receive them on the tarmac. A short statement published on the state-run Qatar News Agency said the 26 Qatari citizens had arrived in the capital, Doha, after being kidnapped in Iraq while they were on a hunting trip.

Qataris on social media shared their elation at the release. With a population of around 2.6 million people, the crisis reverberated across the small country.

Their release was a priority of Qatar's foreign policy for more than a year, said David Weinberg, a senior fellow at the Foundation for Defense of Democracies.

The AP reported last week that a Qatari ruling family member paid $2 million, in an effort involving hackers, to secure the release of the hostages.

Weinberg, who has testified before Congress about Qatar's role in hostage negotiations, said alleged enormous payments paid to a group with ties to al-Qaida creates incentive for future hostage taking. He said Qatar continues to "punch above its weight" in ways that concern some people in Washington.

"This is going to confront the new (Trump) administration in Washington with a serious question ... Is the U.S. administration going to push Qatar to ensure that it does not pay ransom to terrorist organizations in the future," he said.

Defense Secretary James Mattis is due to arrive in Qatar on Saturday as part of his first region-wide official visit since President Donald Trump took office.

Qatar says it does not support extremist groups in Syria or elsewhere, despite aggressive efforts to back Sunni rebel groups fighting to oust the Syrian government, which is backed by Iran and Russia.

The country's ambitious foreign policy efforts haven't always succeeded. Gulf neighbors withdrew their ambassadors in 2014 over Qatar's support for the Muslim Brotherhood group in Egypt, where the group was ousted.

Still, Qatar plays an important role by talking to groups that many governments want to distance themselves from, said Ayham Kamel of political risk consultancy Eurasia Group.

For example, Qatar's capital city of Doha has hosted talks between the Taliban and Afghan government. Qatar has also secured the release of hostages in Syria's civil war, including 13 Greek Orthodox nuns held by an al-Qaida affiliate there.

Kamel says the deal struck to release the Qatari nationals shows that Doha's politics have become more nuanced.