The officer and witnesses said the attacker walked into the restaurant near a police academy and blew himself up.
“The death of five people, two of them members of the police, were confirmed, and more than 10 others were wounded,” Mohammad Abdirahman, a police officer at the scene, told AFP.
“The wounded people were rushed to hospital, some of them with serious injuries.”
Witness Abdukadir Hussein said there had been dozens of people in the restaurant when the blast occurred.
“Many of the people inside were wounded and I personally saw the… dead bodies of two people, the whole area was in a mess as the blast destroyed everything,” he said.
There was no immediate claim for the attack.
The Al-Qaeda linked terrorist group Al-Shabaab frequently attacks civilian and government targets in Mogadishu, which it controlled until it was driven out by African Union troops in 2011.