The deal, signed by the UN-backed Government of National Accord (GNA), local mayors and powerful militias from Tripoli and Misrata provides for an “immediate ceasefire.”
The agreement calls for armed groups that do not recognize the GNA to leave Tripoli within 30 days.
According to GNA’s Defense Ministry, the deal also demands the release of people arrested since fresh battle triggered on Monday.
The Thursday deal cements the UN-backed government’s control over large parts of the capital. It also charges GNA forces with securing areas controlled by rival groups.
The city has been paralyzed amid exchanges of rocket and artillery fire between pro-unity government forces and rival militias, whose members are mainly from Misrata, the hometown of former prime minister Khalifa Ghweil.
The fresh battle saw pro-GNA forces expand their clout in the capital. The forces have taken several districts from rival militias, including groups allied with Ghweil.
On Wednesday night, violent clashes rocked the capital’s southern Salaheddine district.
However, the city and its surroundings were quiet on Thursday morning following the overnight deal.
An inter-Libyan political deal, backed by the UN and signed in December 2015, gave rise to the GNA and called for armed groups to leave Tripoli and other Libyan towns.
The capital is home to dozens of militias. Since taking office, the GNA has secured the backing of several, but many parts of Tripoli remain out of its control.
The unity government wants to see heavy weapons withdrawn from the capital to allow its security forces to operate effectively.
On Tuesday, heavy fighting rocked eastern Libya, where forces loyal to General Khalifa Haftar, the military commander of Libya’s eastern government, regained control of two major oil ports of Ras Lanuf and al-Sidra from a rival faction that had seized them earlier this month.
Haftar’s forces do not recognize the UN-backed government. Haftar was an ally of Libya’s former long-time ruler Muammar Gaddafi but joined the Libyan revolution against the dictator in 2011.
Libya has been rocked by violence since NATO military intervention that followed the 2011 uprising and led to the overthrow and death of Gaddafi. Rival governments were set up in Tripoli and eastern Libya in 2014.