The mayor of the capital of Somalia was badly injured after a suicide bomber walked into his office during a security meeting Wednesday and detonated explosives strapped to his waist.

Police said Mayor Abdirahman Omar Osman and his deputy were rushed to a Mogadishu hospital in critical condition and two district commissioners were among the several dead.

It’s unclear how the bomber managed to enter the mayor’s office. Some security officials said the attacker might have coordinated with corrupt officials, offering them bribes for access.

The Al Qaeda-linked al-Shabab extremist group claimed responsibility.

ISLAMIC EXTREMISTS DETONATE CAR BOMB IN SOMALIA, KILLING 10, POLICE SAY

“The blast injured many local officials including my cousin,” Mohamed Abdullahi, a relative of one of the victims, told Reuters.

The attack occurred shortly after the new United Nations envoy to Somalia, James Swan, had paid the mayor a "courtesy call" and left the compound, an official at the mayor's office told The Associated Press.

The U.N. mission in Somalia in a tweet before the bombing posted photos of the smiling mayor and new envoy, saying Swan had received an overview of the "challenges" in the region.

The bombing comes two days after a car packed with explosives detonated near a busy security checkpoint by the city’s airport. At least 10 people were killed and more than a dozen injured, authorities said Monday.

In that attack, al-Shabab also claimed responsibility. The Somalia-based extremist group often targets government buildings such as the presidential palace and other high-profile targets in Mogadishu with bombings.

CLICK HERE TO GET THE FOX NEWS APP

The security officials said Wednesday's attack appeared to be a shift in tactics as the extremists in the past had rarely managed to infiltrate heavily fortified government buildings without first detonating one or more vehicle bombs.

The group was chased out of the Somali capital years ago but still controls parts of the Horn of Africa nation’s south and central regions and is a frequent target of U.S. airstrikes.

The Associated Press contributed to this report.