Hundreds of migrants held in a detention centre south of the Libyan capital were evacuated this week amid fierce clashes between armed groups, the UN's refugee agency said on Thursday.
Street battles between rival militias raged in Tripoli's southern suburbs from Monday to Wednesday, leaving at least 27 dead and nearly 100 wounded, according to Libya's health ministry.
Some 300 migrants - mainly from Eritrea, Ethiopia and Somalia - at the Ain Zara detention centre were in "clear danger of getting caught in the hostilities," the office of the United Nations High Commissioner for Refugees said.
They were transferred on Tuesday to the capital's Abu Salim detention centre, "which is in a relatively safer location where international organisations can provide aid to them", the UNHCR said.
The evacuation operation was conducted in coordination with other UN organisations, as well as Doctors Without Borders (MSF) and the Libya's Department for Combating Illegal Immigration, it added.
Plunged into chaos following the fall and killing of longtime dictator Muammar Gaddafi in a 2011 NATO-backed uprising, Libya has become a prime transit point for sub-Saharan African migrants making dangerous clandestine bids to reach Europe.
People smugglers have taken advantage of the turmoil, putting African migrants seeking to reach Europe at greater risk.
Many migrants, intercepted or rescued at sea, find themselves detained in detention centres with poor conditions.
In its statement, the UNHCR said it "opposes detention of refugees and asylum-seekers in need of international protection".
The rival militias on Thursday paused the fighting south of the capital after a ceasefire agreement was reached.