At least one suicide bomber used a car packed with explosives to smash open the gates of one of the two hotels, both fortified, guarded, and popular with lawmakers from the nearby parliament, as well as government workers and businessmen.
The twin attacks on the Weheliye and Siyaad were simultaneous and apparently coordinated.
Somalia's National Intelligence and Security Agency later declared the attacks over, adding that at least four militants had been killed.
The security agency said the gunmen were Shebab fighters, calling them "Ugus", the government term for the militants, an acronym in Somali for the phrase, "the group that massacres the Somali people."
More From This Section
Shebab insurgents have carried out repeated attacks in the area, and messages posted on websites close to the al-Qaeda-linked group said the Islamists claimed responsiblity for the hotel raids.
The Islamic militants have stepped up their attacks during Islam's holy fasting month of Ramadan, and the Friday raids came as people settled down to break their daylight fast.
An AFP reporter saw at least two bodies outside the Weheliye hotel, where a car bomb had rammed the front gate.
"There was a loud blast and explosions," said police officer Abdi Dhuhul, adding that the gunmen "stormed the building."
"The terrorists were killed... We have confirmed three civilians dead at Weheliye hotel," said government security official Mohamed Guhad.
The Shebab is fighting to overthrow Somalia's Western-backed government which is propped up and protected by the 22,000-strong African Union force.