The clashes were the deadliest in Tripoli for years and calmed late on Tuesday after one faction handed over the head of a rival faction, whose seizure had triggered the fighting, to a neutral force.
Libya has had little peace or security since a 2011 NATO-backed uprising and it split in 2014 between warring eastern and western factions.
An assault by eastern forces on Tripoli, in the west, collapsed in 2020 leading to a ceasefire that has halted most major warfare. Turkey, which backed the Tripoli government, maintained a military presence in Libya.
However, there has been little progress towards a lasting political solution to the conflict and on the ground armed factions that have gained official status and financing continue to wield power.
Last year factions backing a rival government declared by the eastern-based parliament launched a doomed attempt to oust Prime Minister Abdulhamid al-Dbeibah, head of the interim unity government, leading to a day of heavy clashes in Tripoli.
Sporadic fighting has also this year rocked the city of Zawiya, west of the capital.