The Associated Press put the death toll at 31, citing local officials and the emergency services, an increase from an earlier estimate of 18 people. Special forces troops rescued more than 50 hostages, state news outlets reported.

The attack occurred less than a week after militants from the Shabab extremist group killed dozens of people — both soldiers and civilians, including children — when they stormed a military base in northeastern Somalia.