Fighting in and around Tripoli since 27 August has killed at least 50 people and wounded 138 others, most of them civilians
The UN mission in Libya said it brokered a ceasefire on Tuesday to end a week of clashes in the capital Tripoli that have killed dozens and forced thousands to flee their homes.
Fighting in and around Tripoli since 27 August has killed at least 50 people and wounded 138 others, most of them civilians, according to the Libyan health ministry.
The violence has also forced thousands of people to escape to nearby towns or seek shelter in other districts of the capital, while many more have remained trapped inside their homes.
"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.
Following another day of violent clashes in the capital's southern suburbs, the fighting came to a pause in the early evening but it was unclear if all of the groups involved would respect the agreement.
A ceasefire deal announced on Friday by officials from western cities was only held for a few hours.
After that, UNSMIL invited the "various Libyan parties" to Tuesday talks for an "urgent dialogue on the current security situation in Tripoli".
The UN mission announced the ceasefire hours later on Twitter.
It said the agreement also provided for the reopening of Mitiga, the capital's only functioning airport that has been closed since 31 August due to the clashes.
The agreement "today 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," it added.
The UN mission said among those who took part in the closed-door talks were military officers and leaders of various armed groups present in and around the capital.
Representatives of the UN-backed Government of National Accord (GNA), including the interior minister, also attended the talks.
The Libyan capital has been at the centre of a battle for influence between armed groups since the fall of longtime and autocratic leader Muammar Gaddafi in 2011.
The fighting has pitted armed groups from Tarhuna and Misrata against other militias from Tripoli supposed to be under the GNA's control.
Migrants in Tripoli after being relocated from government-run detention centres in Tripoli (Reuters)
The GNA, which has been unable to form a functioning army or regular security forces, has been forced to rely on such militias to keep Tripoli safe.
Most of the militias formed the backbone of the NATO-backed uprising that toppled Gaddafi.
Since then, rival administrations, including one based in the remote east, and the militias have competed for authority and oil wealth in the North African country.
The UN-backed government said on Tuesday the violence had forced 1,825 families to flee to nearby towns or seek shelter elsewhere in Tripoli.
But many more remained trapped inside their homes and some refused to leave, fearing their property could be looted, said the ministry for displaced people's affairs.
These families had an urgent need for food and water, it said, adding rescuers who had tried to assist them have come under attack from unidentified assailants who also stole ambulances.
The UN rights office expressed concern about the impact on vulnerable people, including migrants.
"Some of the nearly 8,000 arbitrarily detained migrants are trapped in detention centres in areas where fighting has been taking place, without access to food or medical treatment," said spokeswoman Elizabeth Throssel.
Libya is a major departure point for migrants crossing the Mediterranean Sea to Europe, mainly from other parts of Africa.
In a sign of the chaos, hundreds of African migrants escaped from a detention centre caught in the middle of a shootout, an aid official said.
A video posted on social media purported to show hundreds of Africans, some carrying plastic bags, walking in a long line away from the detention centre.
As many as 1,900 migrants had been in the detention centre but some were brought by authorities to another facility, a UN official said.