NAIROBI, Kenya — The death toll from two truck bombs in Somalia's capital soared to at least 276 on Sunday, as the deadliest attack in the country's decadelong war with Islamist extremists signaled that the insurgency is far from defeated despite years of U.S. counterterrorism operations.

Nearly all of the dead were killed by the first bomb, which exploded outside a popular hotel near a busy intersection in Mogadishu, sending a plume of smoke into the sky that could be seen from across the city. The second truck bomb killed a few more people nearby.

The Somali capital is a frequent target of attacks by al-Shabab, an extremist group linked to al-Qaida, but residents said they quickly discerned that the twin blasts were of a different order of magnitude.

The death toll continued to climb overnight. By Sunday night, officials said they were still trying to calculate the number of victims.

A large swath of a city block appeared to be wiped out, and a tower of charred automobiles could be seen at the bombing site. A BBC reporter said people were trapped under the rubble of the Safari Hotel. Throughout Sunday, bodies were being carried from the rubble.

Somalia's president, Mohamed Abdullahi Mohamed, declared three days of national mourning. The government blamed the carnage on al-Shabab, but the group has not claimed responsibility.

"Today's horrific attack proves our enemy would stop at nothing to cause our people pain and suffering. Let's unite against terror," Mohamed said on Twitter.

Medical workers spoke about the scale of the attack, which quickly overwhelmed the city's few hospitals.

"Today is the worst day of my life. We are overwhelmed by the high number of the casualties," said Ahmed Osman, a nurse in Mogadishu's Medina Hospital, where many of the dead and wounded were taken. "I have been working at this hospital for more than seven years, and I never saw or heard this number of deaths,"

The International Federation of Red Cross and Red Crescent Societies said five of its volunteers were among the dead. One volunteer who survived, Abdiasis Mohamed, said he and his friends were drinking tea when one of the bombs exploded. When he regained consciousness, he said, he was covered in blood and several of his friends had been "burned to death."

"Thank God I am fine," he said.

Somalia has been battling al-Shabab insurgents since 2007, with the help of 22,000 troops from the African Union and a U.S. counterterrorism campaign that has expanded under President Donald Trump.

For years, drone strikes were the centerpiece of the U.S. military strategy, carried out with the expectation that the militant group would dissolve if its leadership was vanquished. That has not happened.

Although the U.S. and African Union operations forced insurgents from territory they once controlled, they have not curbed al-Shabab's ability to launch deadly and frequent attacks in Mogadishu, mostly targeting restaurants, hotels and places where officials gather.

Earlier this year, the White House loosened the rules governing American operations in the country, declaring parts of Somalia to be an "area of active hostilities."

A one-star general was assigned to coordinate operations from a compound within Mogadishu's airport. The small, elite teams of U.S. special operations forces in Somalia were augmented with conventional Army troops who provide a variety of training for the Somali forces.

The Pentagon refuses to say precisely how many Americans are deployed to Somalia — it's believed to be a few hundred at most — but Defense Secretary Jim Mattis indicated earlier this year that the Trump administration would consider sending more personnel if asked by the Somali president.

It's unlikely, though, that Sunday's attack will result in any substantial American military buildup there. As in other unstable parts of Africa, the U.S. strategy in Somalia has been to support allied forces by sharing intelligence, providing training and equipment, and conducting precision airstrikes — but not doing the fighting for them.

Mattis has characterized the objective in Somalia as "buying time" for the Somali government to assemble its own security forces. Still, the mission there remains dangerous. In May, a Navy SEAL was killed and two other American commandos were wounded during a battle with militants west of Mogadishu. It marked the first U.S. combat death in Somalia since the early 1990s.

A number of officials were killed in this attack, including Mohamoud Elmi, the director general at the Ministry of Humanitarian Affairs,

In 2016, al-Shabab was the deadliest terrorist group in Africa, according to the Armed Conflict Location and Event Dataset, killing 4,281 people.

Somalia has struggled to maintain a stable government or a defense force capable of challenging the Islamist militants. Last week, both the defense minister and the army chief resigned for reasons that remain unclear. Many analysts argue that Somalia's undeveloped security sector has made it easy for al-Shabab to penetrate the country's largest city with thousands of pounds of explosives.

Earlier this year, the country teetered on the brink of famine, in large part because of the effect of the fighting on agriculture and the distribution of humanitarian aid.

In the wake of the latest attacks, one Mogadishu ambulance service underscored the scale of the bloodshed.

"In our 10-year experience as the first responder in Mogadishu, we haven't seen anything like this," Aamin Ambulance said on Twitter.

In a statement, the U.S. Mission to Somalia called the bombings "cowardly attacks" that "reinvigorate the commitment of the United States to assist our Somali and African Union partners to combat the scourge of terrorism."