A parliamentarian who was at the Muna hotel said there were "dead bodies all over" and he labeled the scene a massacre.
The assault comes after Somalia's most dangerous militant group, al-Shabab, declared a "massive war" on "invaders" - an apparent reference to the 6,000 troops from the African Union that protect the weak Somali government.
African Union spokesman Maj. Barigye Bahoku said it wasn't immediately known how many members of parliament were killed in the attack on the Muna hotel, located a half-mile (1 kilometer) from Somalia's presidential palace. Parliamentarians often live at Mogadishu hotels while in the capital city.
An 11-year-old shoe shine boy and a woman selling tea in front of the hotel were among the dead, Bahoku said.
Since Monday, fighting in Somalia's capital has killed at least 40 civilians and wounded more than 130, said Ali Muse, the head of Mogadishu's ambulance service.
A parliamentarian who was at the hotel when the attack occurred said he had seen at least 20 bodies lying in the corridor of the hotel, including one dead member of parliament. The parliamentarian spoke on condition of anonymity because of fear for his safety.
He said the suicide bomber blew himself up near the reception and then gunmen stormed the hotel, setting off a gun battle that lasted about an hour.
Al-Shabab claimed responsibility last month for twin bombings in Uganda's capital that killed 76 people, saying the attacks were in retaliation for Uganda's deployment of troops with the African Union.
Al-Shabab has increased the use of suicide attacks in recent years, though they are still somewhat rare in Somalia. Veterans of the Iraq and Afghanistan conflicts are believed to be helping train al-Shabab fighters.
Associated Press writer Malkhadir M. Muhumed contributed to this report from Nairobi, Kenya.