Tripoli ceasefire declared after ex-PM injured in shootout
The city has been paralysed amid exchanges of rocket and artillery fire between pro-unity government forces and rival militias including groups allied with former Prime Minister Khalifa Ghweil.
Late Wednesday, the ex-prime minister was wounded in clashes which rocked the capital as loyalist militias battled with the UN-backed governnent for several hours.
His injuries are not life threatening, sources close to him said.
Thursday's deal cements the UN-backed Government of National Accord's [GNA] control over large parts of the capital.
It provides for an "immediate ceasefire" and calls for armed groups that do not recognise the GNA to leave Tripoli within 30 days.
It also demands the release of people arrested since Monday, the GNA's defence ministry said.
The gunfire, triggered Monday night after the killing of a bank guard, saw pro-GNA forces expand their clout in the capital.
They took several districts from rival militias including groups allied with Ghweil, who was forced out of power when the GNA arrived in Tripoli.
The GNA operation appeared to be well-prepared and coordinated.
After three days of clashes, the city and its surroundings were quiet on Thursday morning following the overnight deal, signed by the GNA, local mayors and powerful militias from Tripoli and Misrata. The deal charges GNA forces with securing areas controlled by rival groups.
Observers said it was in line with an inter-Libyan political deal backed by the UN and signed in December 2015.
That agreement, which gave rise to the GNA, called for armed groups to leave Tripoli and other Libyan towns.
Libya has experienced years of violence and lawlessness since the NATO-backed removal of longtime dictator Muammar Gaddafi in 2011, with rival parliaments and governments vying for influence and militias fighting over territory and the country's vast oil wealth.
Since taking power from Ghweil's administration in March 2016, the Government of National Accord has secured the backing of powerful militias in the capital, but some districts remain outside its control.
Ghweil refuses to recognise the GNA's authority.