The Pescatore Seafood Restaurant, which opened recently in the south of the city, was frequented by security and government officials.
Video uploaded to social media shows smoke billowing from the scene of the attack.
Militant Islamist group al-Shabaab claimed responsibility for the blast.
The group’s military operations spokesperson told the Reuters news agency they were targeting “security officers and politicians of the apostate government”.
Al-Shabab, which is allied to al-Qaeda, frequently carries out attacks in Mogadishu as part of its war against the government.
Abdikadir Abdirahman, director of Aamin Ambulance Service, said that they had “carried six dead civilians and seven others injured”.
A number of high profile people – including the Somali police commissioner – are reported to have been at the venue at the time, but there is no indication they were among the injured.
Police officer Mohamed Ali told the AFP news agency that the police commissioner was safe along with “several legislators who stayed there”.
This attack comes amid a surge in violence in recent weeks as politicians have struggled through a much-delayed process to select a new parliament. Lawmakers were finally sworn in last week, paving the way for them to choose a new leader.
On 24 March, a female member of the Somali federal parliament was among more than 30 people who were killed in two suicide bombings in Beledweyne town, in central Somalia.
And on 18 April, seven people were injured in a mortar attack on Somalia’s parliament.