Masteho Abubakr Yusus, Ahmed’s wife, confirmed that her husband had died at the African Union hospital after being shot in the head.
The shooting occurred a day after an explosion killed a Somali official, his wife and four other people in Mogadishu.
Aid workers in the largely lawless country have frequently been subjected to attacks from armed groups.
On June 21, Hassan Mohamed Ali, head of the UN High Commissioner for Refugees organisation in Mogadishu, was abducted from his home on the outskirts of the capital.
UN officials have repeatedly appealed to the Somali government and armed groups opposed to the government to spare aid workers, but they have been forced to scale down operations due to the increased insecurity.
The African Union Mission to Somalia (Amisom) has deployed 2,600 peacekeepers in Somalia – well short of a promised 8,000 troops – and so far it has failed to stem the violence and unrest.
At least 2.6 million Somalis are facing hunger due to acute food shortages caused by a prolonged drought, insecurity and high inflation. The UN’s famine monitors have warned that the figure could hit 3.5 million by the end of the year.