"A martyrdom operation by the mujahideen goes on at Hotel Afrik, which is a cover-up for officials from the apostate government", it said.
Images and video shared on social media showed smoke billowing into the blue skies.
A future Somali government faces a number of urgent challenges, including locust swarms that have devastated crops, the COVID-19 pandemic and hundreds of thousands of Somalis still displaced by drought exacerbated by climate change.
The attack on a hotel in the heart of the heavily fortified city comes as Somali politicians wrangle acrimoniously over delayed elections and follows the withdrawal of around 700 US military personnel last month. Government forces responded to the attack and gunfire could be heard coming from the hotel.
The Information Ministry said in a statement that one of the victims was well known retired military official General Mohamed Nur Galal.
Witnesses say the massive blast occurred Sunday near Hotel Afrik, located in the vicinity of a busy security checkpoint en route to the Mogadishu airport.
They were driven out of Mogadishu by government forces backed by 20,000 African Union peacekeepers in 2011. The attack left at least five Somali civilians and all four al-Shabaab gunmen dead. The fighting lasted into early Monday. Somalia has severed diplomatic relations with Kenya after accusing it of meddling in its internal affairs. Another general and more than 100 civilians were rescued from the hotel, which is near the strategic K-4 junction on the road to the capital city's global airport, Ali said. The group has been moving this money through Somalia's banking system and is investing in local businesses and real estate.
Al Shabab claimed responsibility for the attack through their Andalus radio and Somalimemo website.