ADEN, Yemen — Al-Qaida in the Arabian Peninsula, based in Yemen, is considered the most dangerous branch of the terror network after a series of failed attacks on U.S. soil.

AQAP has been enmeshed in conflicts in impoverished Yemen for nearly 20 years — at times working with the government and at times facing crackdown, all the while building ties among tribes in the mountainous countryside to establish refuges and allies.

___

AQAP'S PREDECESSORS:

The first anti-American attack in Yemen linked to al-Qaida took place in 1992 when a group called the Islamic Jihad Movement attacked a hotel in the southern city of Aden housing U.S. troops heading to Somalia, killing a Yemeni and an Australian. The group was made up of jihadis who had returned from Afghanistan, where they fought the Soviets alongside Osama bin Laden.

The group fell apart after defections spurred by its cozy relationship with ruling authorities as then-President Ali Abdullah Saleh used AQAP fighters to liquidate his top foes, the socialists. Another group called the Aden-Abyan Army was born, also made up of Afghan veterans. It carried out the October 2000 bombing of the American warship USS Cole off Aden, killing 17 Marines. The following year, the central branch of al-Qaida carried out the 9/11 attacks in New York and Washington.

___

AQAP'S BIRTH:

In February 2006, 23 al-Qaida-linked inmates escaped from a prison in the capital, Sanaa. Among them was Nasser al-Wahishi, a personal aide of bin Laden, and Qassim al-Rimi, a prominent militant. Together, they formed the core of a new al-Qaida branch. Three years later, they merged with members of al-Qaida's Saudi branch fleeing a crackdown there: Al-Qaida in the Arabian Peninsula was born, with al-Wahishi as its leader.

The group claimed responsibility for the attempted Christmas Day 2009 bombing of Northwest Airlines Flight 253 as it approached Detroit, foiled when the explosives hidden in the bomber's underwear failed to detonate properly. It next claimed responsibility for a plot uncovered in October 2010 when package bombs originating in Yemen and destined for the United States were found on cargo aircraft.

___

INSPIRATION:

The group was among the first to advocate for "lone wolf" attacks, using its English-language online magazine Inspire, starting in 2010. The magazine has featured articles on such topics as how to make a bomb in a kitchen and hit soft targets in the U.S., such as trains and restaurants. The magazine originally was authored by Yemeni-American al-Qaida ideologue Anwar al-Awlaki and Pakistani-American Samir Khan.

Both were later killed in drone strikes, but al-Awlaki's online sermons and writings remained an inspiration for radicals who carried out attacks in the U.S. and Europe. Al-Qaida's latest overseas attack took place when two militants attacked the offices of the satirical newspaper Charlie Hebdo in Paris, killing 11 people.

___

GOVERNING:

For years, al-Qaida mostly operated by hiding in the mountains, working with tribes. But amid Yemen's political chaos in 2011, it seized the southern cities of Jaar and Zinjibar, imposing a heavy-handed rule under its extremist version of Islamic Shariah law. Government forces finally drove them out in heavy fighting that caused widespread destruction.

AQAP again seized and governed territory in 2015 as the Shiite rebels known as Houthis were pushed back from southern Yemen. Al-Qaida captured Mukalla, the capital of Hadramawt province, and ruled it for a year. The group took a softer approach to ruling, minimizing punishments such as beheading or flogging and focusing instead on development and construction and setting up an administrative council of local figures. Meanwhile, it looted weaponry and millions of dollars.

The group again took control of Zinjibar and Jaar, as well as several areas of neighboring Shabwa province, but subsequently withdrew from those areas under secret deals outlined by The Associated Press.