The violence pitted the Seventh Infantry Brigade from the southeastern city of Tarhuna, previously aligned with Libya’s Tripoli-based Defense Ministry, against the so-called Tripoli Protection Force, which is affiliated with the country’s UN-backed unity government.
At least 15 people were killed and scores injured in the violence.
The ceasefire was announced during a press conference held in Tripoli late Monday, without giving a date when it will go into force.
The deal calls for the withdrawal for 15 kilometers from current positions of the forces of both sides as well as exchanging prisoners and remains of those killed in the clashes.
On Wednesday, the UN Support Mission in Tripoli (UNSMIL) called for rivals to respect a ceasefire reached in September after days of bloody street fighting in the capital.
Libya has remained dogged by turmoil since 2011, when a NATO-backed uprising led to the ouster and death of long-serving President Muammar Gaddafi after more than four decades in power.
Since then, Libya’s stark political divisions have yielded two rival seats of power -- one in Tobruk and another in Tripoli -- and a host of heavily armed militia groups.