A US-backed military coalition led by Saudi Arabia has cut secret deals with al-Qaeda fighters, paying some to leave key cities and towns in Yemen and letting others retreat with weapons and looted cash, an investigation has found.

Hundreds more have been recruited to join the coalition itself.

Again and again over the past two years, the coalition has claimed to win decisive victories that drove al-Qaeda militants from their strongholds and shattered their ability to attack the West.

What the victors didn't disclose: many of those conquests came without firing a shot.

The compromises and alliances have allowed al-Qaeda militants to survive to fight another day - and risk strengthening the most dangerous branch of the terror network that carried out the 9/11 attacks.

Key participants in the pacts said the US was aware of the arrangements and held off on any drone strikes as the al-Qaeda fighters retreated in plain sight.

The findings of the AP investigation are based on reporting in Yemen and interviews with two dozen officials, including Yemeni security officers, militia commanders, tribal mediators and four members of al-Qaeda's branch.

All but a few of those sources spoke on condition of anonymity, fearing reprisals. Emirati-backed factions, like most armed groups in Yemen, have been accused of abducting or killing their critics.

The deals uncovered reflect the contradictory interests of the two wars being waged simultaneously in this southwestern corner of the Arabian Peninsula.

In one conflict, the US is working with its Arab allies - particularly the United Arab Emirates - with the aim of eliminating the extremists known as Al-Qaeda in the Arabian Peninsula, or AQAP.

But the larger mission is to win the civil war against the Houthis, Iranian-backed Shi'ite rebels. In that fight, al-Qaeda is effectively on the same side as the coalition - and, by extension, the US.

The US has sent the coalition billions of dollars in weapons to fight the Houthis, and American jets provide air-to-air refuelling for coalition war planes. The US does not fund the coalition, however, and there is no evidence that American money went to AQAP militants.

"Elements of the US military are clearly aware that much of what the US is doing in Yemen is aiding AQAP and there is much angst about that," said Michael Horton, a fellow at the Jamestown Foundation, a US analysis group that tracks terrorism.

But supporting allies against "what the US views as Iranian expansionism takes priority over battling AQAP and even stabilising Yemen," Horton said.

The AP found that coalition-funded militia commanders actively recruit al-Qaeda militants - considered to be exceptional fighters - or fighters who until very recently were members of the group.

The US is aware of an al-Qaeda presence among anti-Houthi ranks, a senior American official told reporters in Cairo earlier this year.

Because coalition members back militias with hard-line Islamic commanders, "it's very, very easy for al-Qaeda to insinuate itself into the mix," the official said, speaking on condition of anonymity.

The Pentagon denied any complicity with al-Qaeda.