International medical charity Médecins Sans Frontières (MSF) has begun closing all its humanitarian operations in Somalia because of attacks on its staff.
The withdrawal of MSF, also known as Doctors Without Borders, is a blow to the government's effort to persuade Somalis and foreign donors that security is improving despite a stubborn Islamist insurgency.
There was no immediate comment from the Somali government, which is struggling to haul the nation out of two decades of conflict and provides few public services such as health and education.
MSF treated about 300,000 Somalis in the first half of 2013.
MSF International President Unni Karunakara acknowledged the charity's departure would cut off hundreds of thousands of Somalis from medical help.
He said: "The closure of our activities is a direct result of extreme attacks on our staff, in an environment where armed groups and civilian leaders increasingly support, tolerate or condone the killing, assaulting and abducting of humanitarian aid workers."
Within hours of the announcement, al-Qaeda-linked al-Shabaab militants raided one MSF hospital in southern Somalia.
They forced patients out before taking computers, hospital beds and other valuable equipment.
The announcement comes about a month after two female Spanish aid workers employed by MSF were freed by their Somali kidnappers after almost two years in captivity.
In early 2012, MSF shut down two major medical centres in the Somali capital, Mogadishu, after two international staff were shot dead by a former colleague in the heart of the government-controlled city.
Fourteen other MSF staff members have been killed since 1991 when civil war erupted in the country.
MSF had always negotiated with armed groups and authorities on all sides and even resorted to hiring armed guards, something it does not do in any other country, Mr Karunakara said, adding: "But we have reached our limit."