Hundreds of people tried to storm a police station where food was being handed out, they say.
"Police opened fire and killed five people including my brother," said Abdiqadir Mohamed Ilbir, as he wept for his brother, who was among the dead.
Somalia has been racked by violence since it last had a government in 1991.
Earlier this year, up to a third of the population of Mogadishu fled their homes, with aid agencies unable to get enough food for them all.
Some 140 trucks carrying food aid have been stranded at the Kenyan border for more than a month, the UN’s World Food Programme (WFP) says.
Kenya closed its border with Somalia in January to people and commercial traffic but humanitarian assistance has previously been allowed across.
"The people were waiting for food aid that was to be distributed by a local organisation. This is cold-blooded murder," said witness Halimo Abdullahi.
There have also been two attacks on police officers patrolling elsewhere in Mogadishu.
A grenade was thrown at a patrol in the central Bakara market. The police then opened fire, killing a woman waiting for a bus, witnesses say.
And a policeman was fatally shot dead by a gunman.
The government last week imposed a curfew in order to reduce the violence.
The attacks are believed to be carried out by both Islamist fighters and gunmen from the Hawiye clan – the largest in Mogadishu.
Ethiopian and government troops ousted the Union of Islamic Courts (UIC), the Islamist group that controlled most of Somalia for six months last year, in December.
The government is planning a national reconciliation conference next month but Islamist leaders and a growing number of other Somali groups say they will not take part in any peace negotiations until the Ethiopians leave their country.