CAIRO -- When al-Qaida overran the Yemeni port city of Mukalla last month, the group's commanders immediately struck a deal to share power with the area's tribesmen. No jihadi banners were raised. Al-Qaida even issued a statement denying rumors that it had banned music at parties or men wearing shorts.
A local tribal council now administers the city.
The approach was a stark contrast to al-Qaida's rival, the Islamic State group, notorious for its savagery. And that was precisely the point.
In a competition with the Islamic State group for recruits and prestige across the Middle East, al-Qaida has sought to distinguish itself from its rival's bloodthirstiness, taking an approach that in jihadi circles would be considered pragmatic. It is building alliances with local players, even old enemies, to seize new territory. Its leader, Ayman al-Zawahri, has told his followers to avoid IS-style brutalities against civilians in order to build support among local populations.
The strategy has paid off, winning new gains for al-Qaida. In Yemen, it even stands to emerge as the real winner as Saudi Arabia leads an Arab air campaign targeting the terror network's rival, the Iranian-backed Shiite rebels known as Houthis who have taken over much of the country.
Al-Qaida "is the future Trojan horse," warned a senior Yemeni military intelligence officer, Ali Sharif. When the war is over and leaves a security vacuum, he said, "the role of al-Qaida will come. ... They will fill it and take control."
While the United States and the West might hope that the competition between al-Qaida and the Islamic State group would weaken two major militant threats, each is instead maneuvering to benefit from the region's turmoil.
The Islamic State group's gains over the past year have been sizeable. For nearly two decades, al-Qaida was unchallenged as the world's most prominent terrorist organization. But IS has stormed forward to rival it -- and even surpass it in places.
Beyond its heartland in Syria and Iraq, the Islamic State group has planted flags across the map. It eclipsed al-Qaida in Libya, where IS's strongest external branch controls several cities and most of al-Qaida's one-time allies have switched to swear fealty to it. Militants in Egypt's Sinai Peninsula and Nigeria's fearsome Boko Haram -- all once linked to al-Qaida -- have also pledged allegiance to IS leader Abu Bakr al-Baghdadi.
Perhaps more importantly, the Islamic State group has a dynamism and fervor that has seemed to fade for al-Qaida. The IS declaration of a "caliphate" in Iraq and Syria inspired a stream of thousands of foreign fighters to join it and earned it pledges of allegiance by individual militants around the region. The group's notorious brutalities -- everything from beheadings to enslavement of women from religious minorities -- are seen by its supporters as proof of its purity and refusal to compromise on what it considers "God's law."
That has helped the Islamic State group aggressively make inroads in areas long the domains of its rivals.
In Afghanistan, where the Taliban, a top al-Qaida ally, has long dominated, young militants frustrated with the lack of progress in a nearly 14-year insurgency see a winner in IS. In February, former Taliban commanders in southern Zabul province "exchanged their white Taliban flag for the black flag" of IS and were behind the abduction of 31 Shiites, according to Afghanistan's senior Shiite leader, Mohammad Mohaqiq.
"This is a very fertile breeding ground" for the Islamic State group, said Nader Nadery, director of the Afghanistan Research and Evaluation Unit think tank.
Around the Middle East, prominent jihadi clerics to whom militants look for guidance have been split, lining up with one side or the other. The bitterness spills out on social media, where the two sides hurl insults at each other.
Al-Qaida backers gloated when Iraqi troops and Shiite militiamen retook the Iraqi city of Tikrit from the Islamic State group last month. "After all the blood spilled over the delusion of the caliphate, have you finally realized that declaring a nation and emirates only hurts Muslims and jihad?" asked one, with the Twitter handle Jabal al-Aiza.
Islamic State group supporters in turn accused al-Qaida of siding with enemies of Islam against the caliphate. A pro-IS figure on Twitter, Abu Khatab al-Yemeni, denounced al-Qaida's branch in Yemen for allying with anti-Islamist militias that "once were considered apostates."
By building such partnerships, al-Qaida is essentially betting that IS will burn itself out and be weakened by bearing the brunt of the Arab and Western military backlash against its caliphate, while the terror network gains ground through its alliances.
Al-Qaida's approach hardly makes it more moderate, though. In a 2013 document called "General Guidance for Jihadi Action," al-Qaida leader al-Zawahri underscored that the group's priority is to strike "the head of the infidels, the United States and Israel, and their local (Arab) allies."
At the same time, the document urges al-Qaida militants to avoid bloody killings of civilians in order to build support among local populations. They are not to kill Shiite civilians -- even though the group considers them infidels -- or the families of opponents. They are not to harm Christians or bomb mosques or other places where civilians gather.
In Syria, al-Qaida's Nusra Front is the most powerful fighting force outside the territories held by the Islamic State group. Last month, it worked with other rebel factions, including ones backed by Saudi Arabia, Turkey and Qatar, to capture the northwestern city of Idlib and territory in the south -- the biggest victories in several years over President Bashar Assad.
In Yemen, al-Qaida has been boosted by the fight against the Iranian-backed Houthi rebels, who overran the capital, Sanaa, and much of the north and are fighting to take the south after driving the internationally recognized president, Abed Rabbo Mansour Hadi, out of the country.
Al-Qaida "has emerged as the only real fighting force countering the Houthis," said Adaki Oren, an analyst with the Long War Journal, which monitors militant groups. "They have championed themselves as the vanguard of Sunni tribes."
The militants overran Mukalla, the capital of Yemen's largest province, Hadramawt, in early April. That brought it a flood of weapons and cash. But the group quickly stepped into the background. An umbrella group known as the Sons of Hadramawt is policing the city, made up of tribal fighters, local youth and al-Qaida militants. A local council is running government institutions in the city and even won the support of Hadramawt's pro-Hadi governor, who also has fled abroad, a spokesman for the council, Lutfi bin Saadon, told the AP.
When rumors circulated that al-Qaida was imposing strict Shariah rules in the city, including banning music at parties and forbidding use of "qat," a stimulant leaf chewed by Yemenis, the group issued a statement denying the reports and saying they were spread by those opposed to the tribes cooperating with al-Qaida.
The group says it is avoiding taking over territory to rule itself because that would distract it from fighting the Houthis and from its ultimate goal of targeting the United States -- and perhaps draw U.S. drone strikes that have taken out a string of its prominent figures.
Still, its influence among local fighters worries some Yemenis. Across the south, it has allied with local militias, giving backbone to anti-Houthi fighters.
"Sleeper cells of al-Qaida are now awakening, thanks to Houthis," said a southern activist, Adnan Agam. "The south will become a new Afghanistan. ... It won't be one or two cities under al-Qaida control, but all of the south."
Associated Press writers Ahmed al-Haj in Sanaa, Yemen, and Lynne O'Donnell in Kabul, Afghanistan, contributed to this report.