Nairobi - Hopes that Somalia may soon turn the page on decades of anarchy have been dealt a string of blows, giving the internationally-backed government little to cheer as it marks its first birthday.

Al-Qaeda-inspired fighters, breakaway regions, rival clans and an ongoing climate of rampant insecurity have conspired to ensure the Horn of Africa nation remains saddled with its basket case image.

The new government was the first to be given global recognition since the collapse of the hardline regime in 1991, and billions in foreign aid has been poured in.

But in a major blow this month, Doctors Without Borders (MSF) - an aid agency used to working in the world's most dangerous places - pulled out after two decades in the country.

The agency said it could no longer put up with a "barrage of attacks", including kidnappings, threats, lootings and murder.

"It came at a moment when world leaders, for the first time in decades, began making positive noises about a country on the road to recovery and with a stable government," said MSF president Unni Karunakara.

"For them, the timing of our decision could not have been worse."

Somalia has taken steps forward, particularly in the coastal capital of Mogadishu -- now busy with labourers rebuilding after Islamist Shabaab fighters fled their city trenches two years ago.

But the situation elsewhere remains bleak.

"Rarely has it been so important to bear in mind the old maxim: Mogadishu is not Somalia," argues Matt Bryden, in a report for the Center for Strategic and International Studies (CSIS).

Suicide attacks

"The stream of returnees, investors, aid workers and diplomats to Mogadishu has not been replicated elsewhere in the country, creating an artificial, almost surreal bubble of optimism."

Mogadishu's government, selected in a UN-backed process in August 2012, was hailed as offering the best chance for peace in a generation.

British Prime Minister David Cameron, speaking in May ahead of an international conference on Somalia in London, said then that the steps forward had "exceeded all expectations".

But the South African-based Institute for Security Studies (ISS) noted that progress has been "painstakingly slow".

"The failure of President Hassan Sheikh Mohamud's administration to consolidate power beyond Mogadishu and the general lawlessness in many parts of country, remain stark reminders of the huge challenges to lasting peace in Somalia," ISS added.

Outside the city, the weak central government has little influence, with much of the country fractured into autonomous regions, including the self-declared and fiercely independent northern Somaliland.

The northeast Puntland region cut ties with central government in a furious row earlier this month, while in the far south self-declared leaders of the Jubaland region defy Mogadishu's authority.

The Shabaab too remain powerful, despite losing a string of key towns and leaders carrying out bloody purges of rivals.

Suicide attacks on a UN compound in June demonstrated the Shabaab’s ability to strike at the heart of the capital's most secure areas.

Sexual violence

The UN Monitoring Group reports last month estimated the Shabaab are still some 5 000 strong, and remain the "principal threat to peace and security to Somalia".

Multiple armies fight for control of southern Somalia, including rival warlords, Islamist extremists and a rag-tag national army backed by the 17 700-strong African Union force.

Aid workers are struggling to contain a dangerous outbreak of the crippling polio virus, with the UN warning that while more than 100 cases have been recorded there are "probably thousands more with the virus".

Compounding the problem is an almost impossible environment for aid workers.

"This acceptance is now shared by many armed groups and many levels of civilian government, from clan elders to district commissioners to the Federal Somali Government."

Over a million Somalis are refugees in surrounding nations and another million are displaced inside the country, often in terrible conditions, with the UN warning of "pervasive" sexual violence.

Investigations were launched last week after a Somali woman alleged she was gang raped by African Union troops and Somali soldiers.

Progress in Somalia is relative, but steps forward have been taken since the 2011 famine that struck large parts of the south of the country, including in camps in the capital.

"The gains are fragile, however, and the magnitude of the crisis remains enormous," United Nations Humanitarian Co-ordinator Philippe Lazzarini said, adding that more than 2.7 million Somalis were still dependent on aid.