There are also worries about what will happen if those international forces withdraw from Somalia, which could happen as early as next year.
The government has come under intense criticism for a conspicuous policing failure that helped enable the truck bombers.
“The security was absolutely weak,” said Mohamed Abdirahman Mohamed, a student at Mogadishu University.
Mohamed Sharif, another student, described it as a “disaster.” Though he is no stranger to explosions, he said, this one was of a kind “I’ve never heard before.”
In one early sign of the political fallout, Somalia’s Internal Security Ministry said that its spokesman, Ahmed Sayid Arab, had resigned and that a replacement had been appointed.
The African Union, which has about 22,000 troops stationed in Somalia, warned that it was “now clear that without adequate and appropriate support in Somalia, many of the security gains made in recent years could be reversed.”
This summer, Somali lawmakers and some international donors claimed to have seriously weakened the Shabab amid efforts by the United States and African-backed forces, called Amisom, to contain the insurgency by wresting control of Shabab-held territories and killing key figures of the organization in drone strikes.
At a conference in London in May, world powers agreed on plans to support and train Somalia’s army and take over a task currently performed by African Union troops.
However, analysts say that the Shabab’s capacity for mayhem remains far from diminished. In fact, in recent weeks, Shabab operatives have been gaining ground. On Saturday, as the bombs went off, the group took over the town of Bariire, just 31 miles from Mogadishu in the Lower Shabelle region.
“It’s a cold, cold blast of reality,” said David Anderson, a professor of African politics at Warwick University in Britain.
The Shabab had never really disappeared. “It is a guerrilla organization that is really quite efficient in what it does. It makes fewer attacks now but kills far more. The Shabab are getting better at targeting, as this attack shows.”
The bombings were carried out by drivers of two trucks, crammed with explosives, who drove through multiple checkpoints on a tightly patrolled highway. Their easy access raised questions over whether Shabab infiltrators had compromised security.
“No one likes to talk about this, partly because it’s difficult to quantify,” Professor Anderson said. “It’s widely accepted that most of the institutions and organs of the Somali state are infiltrated by the Shabab.”
Whether that was an element in truck bombers’ attack is unclear, he said. But “it’s certainly part of the problem.”
The bombings also highlighted divisions within the government, particularly the security services, and the weakness of President Mohamed Abdullahi Mohamed, who came to power eight months ago with high expectations. His leadership has been further undermined by infighting among clans that control different parts of the government, which may have made the capital more vulnerable to Shabab attacks.
“One of the problems is that there is growing discontent within the security services,” said Rashid Abdi, the Horn of Africa director at the International Crisis Group.
When President Mohamed took office, he promised to pay salaries — the security forces had not been compensated for months — and improve training. But he has been unable to resolve some underlying disputes between the Somali National Army and the security services.
Just before the Saturday attack, the defense minister, Abdirashid Abdullahi Mohamed, and Somalia’s military chief, Gen. Mohamed Ahmed Jimale, both resigned unexpectedly and without explanation.
“There was a lot of friction, parallel commands, which bubbled to the surface,” Mr. Abdi said. “That should have sent of a clear warning signal, and the Shabab took advantage of that situation.”
In recent years the Shabab have also capitalized on growing religious conservatism in the region, propelled by poverty and despair. Moderate gains in recent years as measured in elections and more inclusive government could easily disappear, analysts say.
“There are large parts of the country lacking in opportunities and livelihoods, and the Shabab have been able to take advantage of that,” said Ahmed Soliman, an expert on Somalia at Chatham House, a research organization based in London.
“The solution for the Shabab isn’t to drone-strike it away,” he said. But if international interest in Somalia diminishes, “there can be an unraveling of the progresses made in government and institutions.”