African Union troops and government forces say they have regained control of the hotel after a fierce gun battle.
The hotel is popular with Somalia`s members of parliament.
A website associated with al-Shabab claimed responsibility, saying that fighters from the al-Qaeda linked group had infiltrated the hotel after an explosion.
The attack comes a day after deadly clashes between jihadist fighters and African Union (AU) troops in the Bakool region near the border with Ethiopia.
The AU is helping the government battle al-Shabab, which is linked to al-Qaeda.
Security in Somalia has improved, but al-Shabab still attacks Mogadishu regularly.
The militants have also targeted neighbouring countries, killing almost 150 people in an assault on Garissa University College in Kenya in April.
More about: