Medecins Sans Fontieres is withdrawing non-Somali staff from a hospital in Mogadishu where two of its staff were shot dead but the aid group hopes to maintain its operation in Somalia despite the danger, an official said on Friday,

Meinie Nicolai, president of MSF's Belgian branch which runs the hospital in the Somali capital, said Thursday's attack did not appear to be politically driven.

For us to leave Somalia would be a last option, Nicolai told Reuters.

It is not a political action as far as we can read it today, she added. It's not against the organisation.

The hospital is the largest of MSF's 13 projects in Somalia.

A Somali gunman, himself an employee of MSF, shot dead two international staffers there - an Indonesian doctor and a Belgian emergency coordinator.

The gunman, who worked as a logistics officer, was seen being dragged from the building still holding a pistol as he was taken into custody.

A Brazilian and some Kenyan staff were transferred to Nairobi, Kenya's capital, for security reasons, Nicolai said.

Somalia descended into chaos in 1991 after dictator Mohamed Siad Barre was ousted and has not had a functional central government since.

Last week, a gunman killed three Somali aid workers, including two with the U.N. World Food Programme, in the central town of Matabaan.

For us it's a big dilemma, Nicolai said. We know Somalia is one of the most dangerous places to work, but the needs of the Somalis are so high. If you asked us where MSF should remain working, I would say Afghanistan and Somalia.

MSF said those killed were 53-year-old Belgian Philippe Havet and 44-year-old Indonesian Andrias Karel Keiluhu.

The paediatric hospital has 130 beds and has treated some 15,000 severely malnourished children so far, said Nicolai, adding that it gets about 100 new cases of cholera each week.

More than 100 Somali staff at the hospital will continue to run it, Nicolai said.

ANALYSING THE INCIDENT

MSF will decide which steps to take after further analysing the shooting, Nicolai said.

MSF, or Doctors Without Borders, operates in a number of locations in Somalia, providing emergency aid to people suffering from famine and widespread violence.

The attack happened in a bustling part of the capital, which is under the control of the government and African Union troops.

In mid-October, gunmen kidnapped two Spanish aid workers for MSF in Kenya, near the Somali border.

(Reporting by Sebastian Moffett; Editing by Alessandra Rizzo)