Dakar - After devastating back-to-back civil wars in Liberia, the UN launched a peacekeeping mission in September 2003 to ensure security, rebuild police and military forces from scratch, and disarm rebels.
On June 30, the mission known as Unmil finally hands back security to Liberia's military and police.
But have its goals been achieved and why did it take so long?
In August 2003 a peace agreement was signed in Liberia that ended the second of two civil wars that killed hundreds of thousands and displaced many more.
The four-year war pitched rebels unhappy with then president Charles Taylor, a former warlord and rebel leader, against troops loyal to him.
Many of these fighters had barely hit their teens when they took up arms, but went on to seize four-fifths of the country, some backed by neighbouring Guinea.
The United Nations Security Council cited the number of internally displaced people, the dire humanitarian situation and the need to oversee the implementation of the ceasefire as reasons for an immediate deployment of a large peacekeeping mission.
Sweeping UN sanctions were imposed after the conflict, including travel bans, assets freezes and a ban on lumber and diamond exports.
The first of 15 000 peacekeepers began arriving on October 1, 2003, replacing west African troops who guarded the seaside capital Monrovia.
The mission began with a huge disarmament campaign which got off to a rocky start with former fighters and government troops rioting in protest at door-to-door searches for weapons.
A disarmament programme enrolled more than 96 000 men, women and children who handed in about 27 000 weapons and millions of rounds of ammunition in 2004 alone.
Liberia's former security forces were dissolved, and a new police and military force began training in compliance with the 2003 peace deal.
The dissolved troops were loyal to Taylor, who later became the first ex head of state to be convicted for war crimes by an international tribunal. He was accused of planning, aiding and abetting war crimes in neighbouring Sierra Leone in 2012.
His forces terrorised and brutalised Liberians during the country's own conflict, and were seen as too politicised to stay in place.
Police training began in 2004, and by 2008 Unmil had trained 3 662 new police agents.
Some new recruits were quickly accused of committing crimes themselves and faced allegations of incompetence.
The US government sponsored the revamping of the Armed Forces of Liberia (AFL), out-sourcing the training of the force to a private company, Dyncorp International.
According to the most recent figures available, Liberia's armed forces stand at 2 050 personnel, along with 5 170 police, according to a UN report.
By contrast, Unmil had 3 745 uniformed personnel as of March 2016, comprising 2 592 troops, 71 military observers and 1 082 police.
This will drop under 2 000 by June 30.
The police still have a poor reputation among locals, according to experts, and face an uphill battle with little equipment and very low salaries. Most are unarmed.
Liberia must also ensure security along its porous border with Ivory Coast, which is also emerging from years of turmoil.
Authorities and UN experts have blamed armed groups operating from Liberia for a string of attacks on western Ivory Coast, while tens of thousands of Ivorians have sought refuge in Liberia during the years of unrest in their country.
Former combatants, including teenagers who had known nothing other than a life of conflict, continued to pose a headache for national security forces and the UN long after the conflict wound up.
Since the end of the war, there was little sympathy for ex-child soldiers, many of whom committed the most depraved abuses. Thousands of young men and women remain traumatised and often jobless well into their thirties.
Robberies and burglaries have hit Monrovia successively since 2003, carried out by adults who as children missed out on schooling because they were recruited by rebels to kill and maim.
Budgetary constraints are severe. Unmil has a $344m annual budget, while the draft national security budget for Liberia for 2016/2017 is only about $90m. The document described the coffers as "exceptionally constrained" at a time when "the country faces critical security and democratic transitions".
There is also concern that the security sector remains politicised and that appointments are made on the basis of connections.
In May 2016 the UN Security Council voted unanimously to lift an arms embargo on non-state groups, the last punitive measure in force, a decision that will be closely watched in Liberia.