Years of setbacks have weakened the once mighty Yemeni branch of Al-Qaeda, but the militants are seizing the opportunity to regenerate while the government and Huthi rebels are locked in a fight to the death in the north.
Government security officials and tribal leaders told AFP that the fierce battle for Marib, which has raged for the past month, is creating a security vacuum that is being exploited by the jihadists.
Once seen as the most potent Al Qaeda franchise, they have suffered multiple defeats in the past three years, leaving them deprived of territory and fighters, and with mystery surrounding the fate of the leadership.
"The governorate of Marib has been AQAP's main stronghold for years," said one intelligence official.
While the main combatants in Yemen's six-year war sustain heavy losses in an effort to control Marib city, Al-Qaeda in the Arabian Peninsula remains "at ease" elsewhere in the region where it retains strong influence in villages and small towns.
"As others get busy fighting, they are training fighters again, planning, rebuilding relations" with local tribes and chasing "financial support" from local communities, the official added.
Marib city, the capital of the oil-rich governorate, is the last northern stronghold for the internationally recognised government which is backed by a Saudi-led military coalition.
The Huthis control the rest of the north after years of conflict which has plunged Yemen into the world's worst humanitarian crisis.
"The war in Marib could be ending the maximum pressure campaign that almost wiped (AQAP) out" in Yemen in the last few years, another Yemeni intelligence official said.
Born at a meeting of jihadists on a January evening in 2009, in southern Abyan's rugged mountains, AQAP was a marriage of convenience between the network's offshoots in Yemen and Saudi Arabia, as they faced the onslaught of US and regional military campaigns.
The group led by Nasser al-Wuhayshi and his deputy Said al-Shihri, former prisoners in Sanaa and Guantanamo respectively, found immediate success as Yemen grappled with growing instability -- a secessionist movement in the south, a rebellion in the north, and a crippling economic crisis.
In one year, the group recruited hundreds of fighters with the help of local tribes, attracted jihadists from Asia and Africa, claimed deadly attacks, and attempted to kill a senior Saudi official and bomb a US civilian plane.
It even issued one of the first English online jihadist magazines, called Inspire.
Even before that, the shadow of al-Qaeda hung over Yemen -- the group claimed responsibility for the 2000 attack against the destroyer USS Cole in the southern city of Aden that killed 17 US military personnel.
By the end of that decade "they had a strong basis for their movement and many safe havens," said Hossam Radman from the Sanaa Center for Strategic Studies.
AQAP peaked in 2014, invading towns and taking control of the southern city of Mukalla in 2015, while its main competitor the Islamic State group was gaining ground in Iraq and Syria.
Outside Yemen, the group attacked the French satirical publication Charlie Hebdo in 2015, killing 12, showing its ability to strike far from home.
"It is logical that the continuation of the battle in Marib and the inability of any of the two sides to win will be a major gain for the organisation as it rearranges its ranks," said Saeed Bakran, an expert on Yemeni extremists.
When Saudi Arabia launched a military intervention in Yemen in March 2015, aimed at halting the Huthis' astonishing gains, its eye was also fixed on AQAP.
The UAE, a key member of the Saudi-led coalition, took the lead in driving AQAP out of villages one after the other with the help of US forces, weapons, and intelligence.
US drones and special forces managed to locate and kill leaders including the long-feared Al-Wuhayshi in 2015.
Another challenge was the ambition of the Islamic State, as the rivals tussled for territory and support over the years.
"All these elements weakened AQAP. Today, it is facing financial problems, many members are accused of treason, and others joined IS," a tribal leader in Marib told AFP.
Despite that, it "continued to exploit the security vacuum created by the ongoing conflict" and to "conduct attacks and operate in areas of southern and central Yemen with relative impunity," according to a 2019 US report on terrorism.
AQAP fighters are estimated to number in the low thousands, according to the report.
Then came the battle for Marib, some 120 kilometres (75 miles) east of the rebel-controlled capital Sanaa.
"The fighting is helping the group reorganise. They even pushed some of their fighters to join the ranks of the resistance battling the Huthis, to benefit from the financial support they receive," the tribal leader said, referring to salaries believed to be paid by the coalition.
Last month, the group called on Yemenis to raise arms against the Huthis in Marib, portraying itself once again as the "defender of Muslims" in the region.