A police officer, Ahmed Abdulle, told Xinhua that security forces manning the presidential palace repulsed militants who were trying to storm into the palace, killing three of them.
"They tried to storm into Villa Somalia but our forces fought them back. The forces were pursuing the vehicle as it headed towards the palace but exploded before reaching the target," Abdulle told Xinhua.
The first explosion went off at around 6 p.m. local time, when a vehicle loaded with explosives hit the newly opened Dorbin hotel near the intelligence headquarters.
A second expolsion went off shortly after near Villa Somalia.
Witnesses recounted of the turn of the events.
"We heard a huge explosion followed by a lot of gunfire near the parliament building. We were told Sayidka hotel was being attacked," Yasmin Mohamed said.
Militant group al-Shabaab has claimed responsibility for the attack, which came barely a day after Security Minister Mohamed Islow warned of a minivan loaded with explosives in Mogadishu.
Security forces have in the past week cordoned off roads and launched major security operations in the city amid reports of an impending attack.