Somali security forces arrested the man, a witness told AFP, while a police officer identified him as a Somali employee with Medicins Sans Frontieres (MSF – Doctors Without Borders).
The shooting is the latest attack on humanitarian officials in the Horn of Africa nation, one of the most dangerous places in the world for aid workers and one of the regions that needs them most.
MSF confirmed that the incident took place inside its compound in the Somali capital but was unable to comment on casualties.
“We confirm that a serious shooting incident has taken place in the MSF compound in Mogadishu. At this point we don’t have more information about the scale and the extent of this incident,” the organisation said in a statement.
“MSF is doing everything it can to ensure the security of its staff.”
The police officer said the gunmen may have been fired, while local MSF staff said he had quarrelled with his employers the day before.
Staff at Medina hospital said one man, who they described as a Westerner, was dead on arrival.
His colleague, whom they identified as an Indonesian, had been hit in the thigh, with the bullet piercing an artery and causing heavy bleeding.
“The second victim died at the hospital as doctors were trying to save him,” Dumiya Ali, deputy director of the Medina hospital said later. The victim had already lost a lot of blood when he arrived at the hospital, she said.
MSF said it would probably issue another statement on Friday.
Local MSF staff said the gunman, a logistics officer, had quarrelled with his employers Wednesday and returned to the MSF compound armed on Thursday.
They said he shot the first aid worker three times and his second victim once before exchanging fire with the security guards at the compound who tried to apprehend him.
“The gunman has been arrested. He will be questioned tomorrow (Friday),” said Somali security officer Mohamed Ibrahim.
Mogadishu, the scene of frequent clashes pitting insurgents against pro-government troops, is one of the world’s most violent capitals.
Last week a gunman killed three Somali aid workers, including two World Food Programme staff, in the central Hiran region.
In mid-October two Spaniards working for MSF were seized by gunmen in Kenya’s Dadaab refugee camp that lies 100 kilometres (60 miles) from the Somali border and that is home to several hundred thousand Somali refugees. The two women were driven into Somalia by their captors.
The head of the UN refugees agency Antonio Guterres described the kidnapping as “unacceptable”.
Three regions of south Somalia are still in a state of famine, and close on 250,000 people are in danger of dying of starvation, according to the UN.
Somalia, ravaged by nearly uninterrupted civil war for the past two decades was also the Horn of Africa country hardest hit by this year’s bruising drought.