Kampala — The swearing-in last week of Somalia's new President Mohamed Abdullahi "Farmajo" was greeted with a surge of optimism on the streets of Mogadishu that a new era of stability was on its way.
He won by a landslide, on a wave of nationalist fervour. But the fact that the ceremony took place in a highly secured airport zone, under the control of African Union peacekeepers, in a city repeatedly bombed by the jihadist group al-Shabab, betrays how huge the task confronting him is.
The International Crisis Group's latest report said Farmajo had benefited from being seen as the right leader "to build a robust Somali National Army (SNA), speed up the African Union Mission in Somalia (AMISOM)'s exit, stabilise security, curb interventions by neighbouring countries, and protect Somalia's dignity and sovereignty."
But this is an ambitious wish list and the path ahead is fraught with danger.
Central to Somalia's security is the 22,000-strong AMISOM multinational force. It has been in Somalia for a decade, battling al-Shabab and helping slowly expand state authority.
AMISOM is due to start withdrawing its troops from October next year and is expected to be fully out of the country by December 2020, handing over to the SNA, which will probably number just 20,000.
"AMISOM alone cannot defeat al-Shabab," said a report last year by Mogadishu's Heritage Institute for Policy Studies (HIPS). "This can only happen if AMISOM can partner with a capable, legitimate and inclusive set of Somali security forces."
But the Somali National Army is a force beset with problems, particularly over corruption, capacity and its acceptance in regions beyond Mogadishu. At the moment, there are doubts it will be able to stand up to a degraded, but still dangerous, insurgency.
Francisco Madeira, AU special representative to Somalia, is painfully aware of that challenge. "Building the capacity of the Somali National Security Forces is something that is central to the mandate of AMISOM, and we are doing this to the best of our ability and within the available resources," he told IRIN
Given this, and the historically weak and divided nature of the Somali state, experts fear AMISOM's departure will be premature.
"It seems highly unlikely to me that the Somali army [and state institutions] would be ready in just three years, given the current state of the security situation," said Nina Wilen, a research fellow at Université Libre de Bruxelles.
"A withdrawal of AMISOM in 2020 will be untimely," agreed Christian Ani Ndubuisi, a researcher at the Institute for Security Studies. A more viable option, he believes, is for international donors to support a longer transition, of five to 10 years.
The challenge for AMISOM is that exiting Somalia with some honour hinges on several factors beyond its control. Crucially, it relies on international funding, and not enough has been forthcoming "to seriously degrade rather than simply displace al-Shabab", said the HIPS report.
AMISOM draws its main fighting forces from Uganda, Ethiopia, Kenya and Burundi. Allowances for the troops are paid by the EU, and logistical support - from food to medical supplies - is provided by the UN. The attack helicopters it desperately needs have not been available.
There is also now trouble in the ranks of the troop-contributing nations, which have threatened to withdraw ever since the EU cut the monthly allowance paid to soldiers by 20 percent in January 2016, from $1,028 to $822.
While the AU argues that its soldiers bleed and the West provides only money, the EU counters that there are other peace operations on the continent deserving of its support, including Central African Republic, Mali and the Lake Chad crisis.
"AMISOM will celebrate its 10th year this year, and the main funder [the EU] does not see the light at the end of the tunnel," said Thierry Vircoulon, ICG project director for Central Africa. "It is not ready to fund another never-ending peacekeeping mission as the UN usually does."
Chicken and egg
AMISOM does not have the manpower or equipment to comprehensively defeat al-Shabab, yet cannot secure additional funding until it demonstrates greater battlefield success.
But defeating al-Shabab is not just a military undertaking. The Somali government has been unable to consolidate the territorial gains made by the AU troops, including providing much-needed services and security to the people.
That means the "ideological foundation of the group remains hard to dismantle within the local population," said Ndubuisi of ISS.
Additionally, Somalia is a federal state with its autonomous regions in uneasy alliance with Mogadishu and at times testy relations with each other. These regional forces have greater local acceptance than the SNA.
"The state formation project in Somalia is still marred by ongoing disputes between autonomous regions," explained Ndubuisi. "How can the different regions in the country collaborate for a common purpose?"
The AU's answer is a surge of troops to weaken al-Shabab before the 2018 draw down. On 16 January, it asked the UN Security Council to authorise an additional 4,500 soldiers for a non-renewable period of six months.
"We have concluded plans to recover the last strongholds that the al-Shabaab holds in Somalia, specifically in the Lower Juba region," said Madeira, the AU representative. "To do this, however, we need additional troops, just for this assignment, after which the troop numbers will return to previous levels."
But AMISOM may not be the perfect instrument for Somalia's renewal, especially for nationalists in Mogadishu. For a start, there have always been question marks in Somalia over the AU intervention, especially when regional rivals - Ethiopia and Kenya - joined the mission.
"Initially, [AMISOM] did a lot, particularly pushing al-Shabab from urban centres," said Abdirashid Hashi, one of the HIPS report's authors. "Then Kenya and Ethiopia entered Somalia, pursuing their own national security interests, and were rehatted [as AMISOM] so the UN/EU can foot the bill."
The critical piece in the puzzle, argues the HIPS report, is the need for a political settlement in Somalia that encompasses the federal government and the regional administrations.
"This settlement must include agreement on how to govern Somalia, a shared vision of the roles of the country's security forces and a roadmap for integrating the numerous armed groups that currently proliferate," it noted.
Hashi argued that "only a well-armed and well-trained Somali security apparatus can, in the long run, address the insecurity and instability enveloping the country."
"Much could be achieved in three years if Somalis get their act together and seriously focus on fixing their ailing state, and if the international partners provide genuine support," he added.
Farmajo's mandate is indispensable to make progress on those multiple fronts, particularly reconciliation, addressing corruption and finalising the constitution, said the ICG report. The upcoming London conference in May, where donors will be present, could also help.
Al-Shabab, meanwhile, has vowed to fight Farmajo as an "apostate". In a defiant message released earlier this month, a commander bragged: "We know how to eat cheese," a reference to the president's nickname, an approximation of the Italian word for "cheese".
But there have been suggestions that the insurgency is worried by his popularity. Dissident commander Mukhtar Robow Abu Mansur, who leads a "nationalist" wing of al-Shabab, has reportedly considered surrendering.
Any concrete signs of a splintering of the insurgency - there are none yet - would represent a real victory for Farmajo and his project to rebuild Somalia.