Police officer who requested not to be named told Xinhua that the blast occurred during food distribution at the local government building.
“People were getting humanitarian aid when the blast occurred, we can confirm that at least five died in the explosion,” the officer said.
Witnesses said the blast was huge and caused panic among the residents who had lined up to receive food aid.
“We heard huge blast and learned that civilians were hurt in the blast,” Mohamed Nur, a witness told Xinhua.
The al-Qaida affiliated group al-Shabab claimed the responsibility for the latest attack.
The extremist group which has lost several towns said it had targeted police officers, who were meeting at the compound.
The blast came while Mogadishu is on high alert as police forces blocked the main roads of the capital to prevent possible attacks by the militants.
Al-Shabab was ousted from Mogadishu in 2011 but the terror group is still capable of conducting attacks, targeting government installations, hotels, restaurants and public places.