For 15 years, African soldiers have rotated through Somalia as part of a 20,000-strong force mandated by the United Nations to protect the fragile central government from an Islamist insurgency.
But the mission is winding up, with a transitional force given less than two years to hand over security responsibilities to Somalia's national army and withdraw from the troubled country. Will it work?
What is Amisom?
Created in 2007 by the UN Security Council, the African Union Mission in Somalia (Amisom) was tasked with fighting the Al-Shabaab militants bent on overthrowing the foreign-backed government in Mogadishu.
Drawn from across Africa, the mission drove Al-Shabaab out of Mogadishu in 2011, creating enough stability for government and federal agencies to take shape, and two rounds of elections to be held.
"Amisom played a part in securing and providing a conducive environment for politics and for economic activity," said Samira Gaid, executive director of the Hiraal Institute, a Somalia-based security think tank.
But after the early gains, the mission has mainly been on the defensive.
"There was an opportunity in 2014, 2015, to sustain the offensive and have the upper hand against Al-Shabaab... That opportunity was not taken," Gaid said.
Unable to rely on Somalia's poorly-trained and -equipped national army, Amisom resorted to holding its positions as Al-Shabaab gained ground in rural areas and regrouped to launch deadly attacks across the country.
Is it popular?
Many of Amisom's biggest troop contributors -- such as Uganda, Kenya and Burundi -- are majority Christian and Al-Shabaab has tried to paint them as "crusaders" seeking to occupy Muslim lands.
Accusations of rape and murder levelled at Amisom soldiers furthered a level of distrust about the foreign force in Somalia.
The central government has also accused some countries -- notably Kenya, with whom relations are tense -- of using the mission to meddle in Somalia's affairs.
Mogadishu has never hidden its desire to regain control over its own security.
But Amisom remains indispensable for securing strategic assets and supply routes in a country where Al-Shabaab maintains the capacity to launch frequent and deadly attacks.
"Amisom was stuck in a status quo where it wasn't making new progress, but taking it out also would mean a reversal of progress," said Omar Mahmood, a Somalia analyst at the International Crisis Group think tank.
What comes next?
The UN Security Council voted Thursday to replace Amisom with the AU Transitional Mission in Somalia (Atmis).
Atmis has a more offensive remit than its predecessor and calls for security to be assumed by Somalia's army and police force by the end of 2024.
Somalia's government on Friday said it welcomed the decision and was "committed to ensure the transfer of responsibility of security from Atmis to the Somali security forces."
Over that time, troops should be gradually withdrawn in four distinct phases coinciding with major ground operations against Al-Shabaab.
Analysts doubt whether the timetable will be kept -- Amisom was initially mandated for six months, and lasted 15 years.
"We've seen these same timelines time and time again... those timelines are still contingent on ground conditions, and that's been the situation for years," said Mahmood.
There is no big difference between this mission and the last, Gaid said.
"You have the word 'transition' which provides hope... to donors that they are coming to the end of paying for this expensive mission," she said.
"It also gives hope to (the) Somali side that Amisom is on its last legs."
Atmis should prioritise training and equipping Somali forces and investing in security infrastructure, she added.
Can it succeed?
Analysts say progress on security cannot be achieved while the country is stuck in political deadlock.
Elections are more than a year overdue and the process towards completing the vote for parliament, which will in turn choose a president, has been hobbled by power struggles at the highest level of government and feuds with some states.
The deadlines set by Atmis are optimistic considering the uncertainty surrounding the "incredibly divisive" election process, Mahmood said.
"Reconciliation is a prerequisite in order to sustainably implement some of the security dynamics," he said.
Collaboration between Mogadishu and Somalia's federal states on security would also be essential to achieve these outcomes -- trust that in some cases is nonexistent.
Gaid said handing over security to Somalia would take "at best five years, maybe 10".