The United Nations Mission to Somalia, which backs a 19,000-strong African Union peacekeeping mission in Somalia, condemned the attack and called for those responsible to be brought to justice.
The Shabab was driven out of the capital, Mogadishu, in 2011 but still holds sway over wide swaths of the Somali countryside, exerting influence through extortion and links to the business community, even in places where it does not control territory.
The impending American troop withdrawal has emboldened the Shabab to step up its attacks, said Matt Bryden of Sahan Research, a research consulting firm that specializes in the Horn of Africa. “Of course the Shabab are stepping it up, to show they exist,” he said.
Although American drone strikes and Special Operations forces raids inside Somalia are likely to continue after the withdrawal, the pullout is likely to have the greatest effect on the Danab, a 1,000-strong Somali unit whose troops typically operate with close American support.
“Without mentoring, you can already see how they are being used for non-counterterrorism purposes, like standing in line for the prime minister,” Mr. Bryden. “And now two of their commanders have been killed.”
Although the Shabab mostly fights inside Somalia, it has carried out attacks in other parts of East Africa and harbors some ambitions to strike the United States. This week prosecutors in Manhattan charged Cholo Abdi Abdullah, a Shabab operative from Kenya, with plotting a 9/11-style attack on an American city.
Prosecutors said that Mr. Abdullah, acting under orders from the same Shabab commander who masterminded an attack on a hotel in Kenya in 2019, was arrested as he trained in the Philippines to hijack an aircraft and fly it into a building in the United States.
Hussein Mohammed contributed reporting from Mogadishu, Somalia.