(CNN) The US Special Forces raid in central Yemen on January 29 is further evidence of two things: al Qaeda in the Arabian Peninsula (AQAP) remains a formidable, resilient enemy -- and is more deeply entrenched in Yemen's tribal society than ever.

The raid, in the province of al-Bayda, achieved some of its goals. US Central Command said three senior AQAP officials were killed and valuable intelligence retrieved. But it was at a cost, including the death of Navy Seal Team member William "Ryan" Owens , injuries to three other US personnel and the loss of an Osprey aircraft.

An unknown number of civilian non-combatants also were killed, including women and children, according to a Central Command statement. They "appear to have been potentially caught up in aerial gunfire that was called in to assist US forces in contact against a determined enemy," it said.

Yemeni officials have told CNN that 13 civilians were among some 40 people killed during the raid, including six children. The London-based NGO Reprieve and a human rights worker in Yemen put the number of civilians killed at 23. Photographs published Thursday of the scene indicate an intense fire-fight.

Centcom says the SEAL team, supported by soldiers from the United Arab Emirates, were "receiving fire from all sides to include houses and other buildings," which suggests the element of surprise was compromised. Some of the fire was coming from "women firing from prepared fighting positions," the statement added.

"Considering that it now appears that those in the area had some foreknowledge of the operation, it would be far from surprising, for example, if women at the scene took up weapons in self-defense," said Adam Baron, an expert on Yemen.

One aim of the raid was to target members of the Al-Thahab clan, which has long been close to al Qaeda, and which Baron describes as "one of the key tribal families" in the area. Among those killed was Abdul Raouf Al Thahab -- the head of AQAP in the area and the purported target of another US strike in 2012 that ended up killing several civilians.

The AQAP leadership has been regularly targeted by US drone and missile strikes in recent years. Its overall leader, Nasir al-Wuhayshi , was killed in a drone strike (though not apparently targeted) in 2015 and in 2012 a drone killed Fahd Mohammed Ahmed Quso , believed to have plotted the bombing of the US destroyer Cole in 2000.

But AQAP still has a deep bench. Michael Horton, a senior analyst at the Jamestown Foundation and regular visitor to Yemen, told CNN that "the leadership recognizes it will be targeted and therefore actively trains replacements. It's also increasingly diffuse."

What looks to be a botched attack with high civilian casualties will likely only strengthen the resolve of many tribesmen there to support AQAP. Michael Horton, a senior analyst at the Jamestown Foundation

AQAP has ably exploited Yemen's collapse as a state into a fractious and stunningly complex mosaic. It has gained from the Saudi military campaign of the past two years that has targeted the Houthi minority, one of AQAP's enemies in Yemen. The Houthis took control of the capital, Sanaa , and much of northern Yemen in the fall of 2014.

AQAP also learned from its own mistakes. It briefly controlled parts of southern Yemen in 2012 before being driven out by the then US-supported government of President Abd Rabbuh Mansur Hadi.

Letters written by al-Wuhayshi after that setback recommended a more gradualist approach to implementing Islamic law. He acknowledged that local tribes were AQAP's most formidable enemies.

So AQAP changed tactics.

AQAP cultivates the tribes

Horton says AQAP then moved north into the mountains of al Bayda province where it "exploited inter-tribal rivalries by leveraging its access to arms, funds, and the military acumen of some of its ranking members in exchange for safe havens."

A US official confirmed to CNN Thursday that the raid was indeed aimed at better understanding connections between regional tribal fighters and al Qaeda operatives.

Writing in the Combating Terrorism Center's Sentinel journal, Horton says AQAP is "refining its capabilities in multiple areas, and in what is a dangerous parallel with Syria, is deepening its ties to local communities."

One example was its meticulous courting of tribes in the area around Mukalla on the Arabian Sea coast. That allowed AQAP briefly to seize the town in April 2015 - along with an estimated $100 million from the local branch of the Yemeni Central Bank.

Adam Baron says that while a UAE-backed assault eventually forced AQAP out of Mukalla, "the group was still able to bank tens of millions of dollars -- if not more -- during their time in control of the city."

Baron, a visiting fellow at the European Council on Foreign Relations and co-founder of the Sanaa Center for Strategic Studies, told CNN that "AQAP has never been wealthier, while the collapse of the Yemeni government has given them unprecedented freedom of movement."

Horton told CNN that the Saudi-led offensive "has blurred the lines between forces supporting (former President) Hadi, jihadists with a nominal alliance to AQAP, and core AQAP forces. In many cases they are indistinguishable."

The last days of the Obama administration saw an uptick in aerial strikes against AQAP, and much of the planning for the latest and more ambitious assault was also done before President Trump came into office.

But the execution of the mission indicates the new administration is also focused on Yemen, as part of both its counterterrorism strategy and its efforts to contain Iran.

In a statement Wednesday, National Security Advisor Gen. Michael Flynn noted that "Houthi forces that Iran has trained and armed have struck Emirati and Saudi vessels, and threatened US and allied vessels transiting the Red Sea."

Iran has denied arming the Houthis.

But the twin goals of combating AQAP and Iranian influence tend to undermine each other. In Horton's view, "The Trump administration's stance on Iran can only mean continued support for the Saudi war in Yemen -- and will undermine its stated aim of combating AQAP."

Civilian casualties

April Longley Alley , an analyst with the International Crisis Group, says raids that inflict heavy civilian casualties are "deeply inflammatory and breed anti-American resentment across the Yemeni political spectrum that works to the advantage of AQAP."

Horton agrees, telling CNN: "What looks to be a botched attack with high civilian casualties will likely only strengthen the resolve of many tribesmen there to support AQAP."

That's what AQAP hopes for. In a statement after the raid, it focused on civilian casualties and declared that "such American idiocies only strengthen Mujahideen entrenchment among their honorable brothers and tribes throughout Yemen."

Inadequate intel

The latest raid also underlines the difficulty of operations where intelligence is literally thin on the ground. The last known such operation in Yemen was an abortive hostage rescue attempt in December 2014, when a SEAL team tried to rescue an American citizen held by AQAP.

Both the hostage and a South African man were killed by AQAP. Again the element of surprise was lost as US troops approached their target.

Similarly, an attempt in 2013 by US Special Operations Forces to kill or capture a leading figure in Al-Shabaab in Somalia had to be called off after an intense firefight in which civilians were in the crosshairs.

These operations always carry with them substantial risk and uncertainty. Back in 2015, when he was director of the US National Counterterrorism Center, Nicholas Rasmussen said that "the lack of robust US presence in the country significantly complicates our ability to carry out counterterrorism operations inside Yemen."

That presence remains weak today, and Yemen's chaos has grown even worse in the last two years. Combating AQAP remains a long-haul effort.