TEHRAN, Young Journalists Club (YJC) - The move came after Shabaab gunmen staged coordinated bomb attacks Saturday outside the Nasa Hablod Hotel 2 before storming the building.
Two weeks ago, Mogadishu was hit by a massive truck bombing that killed 358 people in the troubled country's worst-ever attack.
Saturday's carnage was unleashed when a car bomb exploded outside the hotel entrance followed by a minibus loaded with explosives going off at a nearby intersection.
The gunmen then rushed into the popular hotel, launching a siege that lasted several hours.
"Five gunmen stormed the building, two of them were killed and the rest captured alive," security ministry spokesman Abdiasiz Ali Ibrahim told reporters, AFP reported.
Sporadic gunfire could be heard inside the building where the gunmen had holed up, but several people managed to escape, officials said.
Officials had initially given a toll of 14 dead, saying "most" of the casualties were civilians although a senior police official and a former MP were among them.
The Shabaab claimed responsibility for the attack in a statement on its Andalus radio station, saying it was a hotel where "apostate officials" were staying.
The latest toll was given by Security Minister Mohamed Abukar Islow at a cabinet meeting at which ministers approved the dismissal of intelligence agency boss Abdillahi Mohamed Sanbalooshe and police chief Abdihakim Dahir Said.
The two were "fired for the purpose of serious accountability," said a statement, which also said police were interrogating the three captured gunmen.
The removal of the officials comes soon after the abrupt resignation of Somalia's defence minister and army chief on October 12, both of whom quit without explanation just two days before the massive truck bombing.
Although a new army chief was named the same day, General Abdi Jama Warsame, the defence portfolio remains vacant.