10:38, 20.Jul 2018
Rival militia factions that have been fighting in Libya's capital Tripoli for the past week have agreed a ceasefire, the United Nations says.
At least 47 people have been killed and 1,800 families internally displaced by the violence, officials say.
Last week, a ceasefire deal announced by officials from western cities only held for a few hours.
A UN-backed government is nominally in power in the capital, but militias occupy much of the rest of the country.
Why is Libya so lawless?
Is it possible to hold elections in Libya?
Libya and migration crisis
"Under the auspices of [UN envoy Ghassan Salame], a ceasefire agreement was reached and signed today to end all hostilities, protect civilians, safeguard public and private property," the Unsmil mission said.
The ceasefire also provides for the reopening of the capital's only functioning airport, Mitiga, which has been closed since 31 August due to the clashes.
The agreement "does not aim to fix all the Libyan capital's security problems; it seeks to agree on a broader framework on the way to start addressing these issues," the mission said.
The talks included military officers, leaders of various armed groups in and around the capital and the UN-backed Government of National Accord (GNA).
This is the third attempt to end the outbreak of violence in Tripoli as the first two ceasefires were broken almost immediately.
This time there's a signed agreement mediated by the United Nations.
Underlying issues still need resolving
By Rana Jawad, BBC North Africa correspondent
If the ceasefire holds, it will be a short-term fix because the underlying issues that drive these bouts of deadly militia violence in Tripoli are rooted in governance, and institutional issues that could take years to overcome.
For the international community, containing this deadly conflict was a priority because it threatened the standing of the only government they can deal with and what has been a painstakingly slow return of foreign missions and diplomats to Tripoli since 2014.
But this ceasefire only buys them time.
Every government that has come and gone, whether backed by the international community or not, has legitimised these competing armed groups on and off, including all those involved in the fighting this past week.
This allowed them to grow more powerful and richer over the years, and for the rivalry to deepen and boil over as it did this month.
As it stands, the authorities need some of them to remain in power because they have not figured out how to do without them. If they can maintain the peace long enough, it may give the UN and member-states a chance to take control of further mediation and new parallel efforts that start finding solutions to the root causes of Libya's troubles.
The armed group that sparked the eight-day conflict posted a statement saying its commander supported the truce; the group claims the agreement includes the departure of its rivals from Tripoli.
Those rivals are militia brigades which are nominally attached to the interior ministry in the Tripoli government.
The violence has forced thousands of people to flee to nearby towns or seek shelter in other parts of the capital, while many more have remained trapped inside their homes.
The violence broke out last week when militias from a city to the south of Tripoli attacked its southern areas, leading to fighting with local militias that support the GNA.
Hundreds of migrants trapped by the fighting have been moved to other detention centres.
Libya has faced continuing chaos since Nato-backed forces overthrew long-serving ruler Col Muammar Gaddafi in October 2011.
Source : BBC