MOGADISHU/NAIROBI — Western powers are in early talks on writing off Somalia's debt, a big shift for a country that was long branded a failed state and has with help scored successes against al-Qaida-linked rebels and piracy.
Just two years ago, Islamist militants and African peacekeepers fought daily street battles in Mogadishu.
Now the city is rid of insurgents, though still vulnerable to attack, and the government's focus is on bolstering security, rooting out corruption and imposing the rule of law.
Foreign diplomats point to a determination to re-enter the international fold under President Hassan Sheikh Mohamud, elected last year in the country's first vote for decades.
This is welcome progress for regional states whose economies have been rattled by their neighbor's instability and for Western capitals which long worried Somalia provides a base for militant Islam to flourish unchecked.
"A couple of years ago all the talk was about humanitarian disasters, piracy and terrorism,'' said a Somalia-focused senior Western diplomat based in the Kenyan capital, Nairobi. "Now we're talking about an arrears process.''
Mohamud had made it clear Somalia should not be seen as a basket case and wants to change donors' attitudes, envoys said.
Discussion about debts suggest that change is happening. Somalia's arrears stood at around $2.2 billion in 2010, World Bank data showed, peanuts in international terms but daunting when domestic revenues are forecast at $54 million in 2013.
Washington, London and Brussels are among those which have formally recognized the government for the first time since civil war erupted in 1991. Diplomats say it is high in ambition but hamstrung by a lack of funds, manpower and expertise.
"This is a better government on every level,'' said a U.N. diplomat in Nairobi. "They're more responsive, more interested in what they're doing and they're not feathering their own nests.''
Security worries persist. Britain warned this week of imminent attacks in Mogadishu and al-Shabab militants have claimed several suicide bombings in past months, more than two years after they were driven out of the capital.
Their fighters still control swathes of the countryside, but an African Union force has forced them out of most cities and the Islamist group is now at its weakest ebb in the six years since it emerged amid anarchy as a fighting force.
The 17,600-strong African force includes troops from Uganda, Burundi and Kenya. Nairobi is worried by a surge in bombings, kidnappings and grenade attacks on its soil that it blames on the Somali militants and their sympathizers.
Mogadishu's mortar-blasted facades and refugee camps tell of chaos inflicted by clan warlords and then Islamists after dictator Mohammed Siad Barre's overthrow set off civil war.
But now its rubble-strewn streets are choked with traffic and constructions sites point to a new confidence. Well-dressed Somali men from the diaspora hold their girlfriends' hands in public - impossible when the strict Islamists were in charge.
"Mogadishu is now like other cities in the world,'' said Hassan Hashi, an elder from Dusamareb in central Somalia.
But he said the government still struggled to exert influence in the provinces. In a country divided along clan faultlines, the government's relationship with the regions is delicate and often uneasy under a fledgling federal system.
Strips of Somalia's coast remain infested with pirates, even if they stage fewer successful attacks now due to the greater use of armed guards, increasingly aggressive naval action and slight improvements in law and order onshore.
"The other parts of the country are dark,'' said Hashi. "Mogadishu, which is the heart of Somalia, has recovered but the other regions, the limbs, are still paralyzed.''
A political newcomer, Mohamud's election was hailed by many as a vote for change, but seven months on some grumble.
"He promised to improve security but it has not yet happened,'' said shopkeeper Halima Bile from Baidoa, which relies on foreign rather than local forces for protection from the rebels. "I don't know when Somalia will become a real country.''
But Western powers are no longer dealing with Somalia as a failed state. Humanitarian aid is still essential, but now they have an interlocutor in the government which increasingly pushes visitors to meet in Villa Somalia, the presidential palace, instead of behind the fortified fences of Mogadishu's airport.
"By treating them as a normal state we're signaling things are really beginning to change,'' said the European Union's envoy Michele Cervone d'Urso, who is still based in Nairobi but spends more time in Somalia. "Of course, it is step by step.''
Some U.N. officials and aid workers are also slowly moving out of Kenya to Somalia, and diplomats will not be far behind.
Britain plans to open an embassy in Mogadishu by the end of July, and other Western powers who left in the early 1990s may follow. It will join others such as Turkey, Sudan and Yemen.
Recognizing Mohamud's government may open the way for more Western aid and funds from World Bank and International Monetary Fund, vital for services like health, education and security.
But Somalia still has a way to go to build foreign confidence. Asked whether direct budgetary support was a possibility, the Western diplomat said: "Not for a long time.''
"I wouldn't say it is a functioning government. It lacks capacity at all levels,'' he added.
But the West is providing more support. Britain says it plans to use its presidency of G8 nations to urge the World Bank and others to re-engage with Somalia.
Almost half Somalia's $2.2 billion of external debt is owed to the IMF, World Bank and African Development Bank. Those debts must be clear before further support is offered.
The World Bank's lead economist on Somalia, Paolo Zacchia, said there was no quick fix but that the bank was looking at acting as swiftly as possible to "stabilize the government''.
Others also want to avoid missing an opportunity to prevent a slip back into anarchy.
"We have to bank these opportunities otherwise they will slide backwards,'' the Western diplomat said. "The gains made are incredibly fragile.''