Armed groups that have been controlling Tripoli for more than a decade have agreed to leave Libya's capital.
Interior minister Imad Trabelsi - part of the internationally recognised government - said after lengthy negotiations a deal had been struck for regular forces to police Tripoli.
He told journalists there would only be emergency police, city officers and criminal investigators in their place.
The deal comes after a series of deadly clashes in the city in recent months.
Libya has been battered by many armed groups who emerged after the overthrow of Muammar Gaddafi in 2011.
A series of armed uprisings that led to the long-time dictator's killing created a security vacuum, with much of the country lawless and chaotic since.
Libya is currently divided between the internationally recognised government in the west, led by interim Prime Minister Abdul Hamid Dbeibah in Tripoli, and an administration in the east run by military strongman Khalifa Haftar.
In a press conference, Mr Trabelsi said from now on the militia's "place is in their headquarters", adding the Libyan government "will use them only in exceptional circumstances for specific missions".
He said once they had left the capital other cities would follow, noting there "will be no more checkpoints and no more armed groups" on roads.
The deal will see at least five armed groups quit Tripoli by the end of the Muslim holy month of Ramadan on 9 April, including one based in an area where 10 people were killed over the weekend.
The militias in question - the General Security Force, the Special Deterrence Force, Brigade 444, Brigade 111 and the Stability Support Authority - are heavily armed and split large swathes of the city amongst themselves.
The groups' visible presence in Tripoli saw them wearing masks and installing checkpoints on roads using armoured vehicles with mounted weapons.
But they were often involved in fighting each other, including one incident in August which left 55 people killed and nearly 150 injured.
They are not under the direct command of the Libyan government, but do receive public funding. Their operational independence was granted by a special status conveyed on them in 2021 by the government.