Despite this week’s killings, senior administration officials characterized their campaign against al-Shabab as highly effective. The organization, a onetime youth militia that began affiliating with al-Qaeda in the mid-2000s, once controlled virtually all of southern Somalia but has lost more than 75 percent of its territory in recent years.

Its grip on Kismayo, where it controlled the lucrative port, had been broken, robbing it of a key source of revenue. These days, the group’s finances have been drained.

This week’s vicious killings in Kenya, carried out by only a small team of masked gunmen, were cited by White House officials as further evidence of the group’s inevitable demise.

“They are desperate,” said the senior administration official, who was authorized to speak only on the condition of anonymity. “And as much as we hate to think about it, this is what desperate groups do. They try to have smaller teams go out and [conduct] higher-impact operations.”