The UN said Tuesday it had evacuated more than 150 refugees from a Tripoli detention centre affected by recent clashes, and said refugees elsewhere might also need to be moved.
The operation came as warring factions in the North African country faced mounting international pressure to halt violence that has killed several dozen people and caused thousands of others to flee.
"In light of current insecurity in Libya's capital ... the UN Refugee Agency today relocated more than 150 refugees from the Ain Zara detention centre in south Tripoli," the UN agency said in a statement.
It noted that the detention centre had been "impacted by heavy clashes in the past few days," and added that the refugees were now in a nearby "safe zone".
UNHCR said this marked its first such relocation since fighting escalated recently in Libya.
The oil-rich country has been rocked by violent power struggles between armed groups since the NATO-backed overthrow of dictator Moamer Kadhafi in 2011.
The UN-backed Government of National Accord (GNA) controls Tripoli, but its authority is not recognised by a parallel administration in the east of the country, allied with strongman Khalifa Haftar, who launched a surprise assault on the Libyan capital last week.
The UN said the clashes have displaced 3,400 people.
Refugees from the Zara centre told UNHCR they were "frightened and worried about their safety, given ongoing fighting in the vicinity, and that they were left with minimal supplies," the statement said.
The agency is looking into reports of similar situations at other detention facilities for refugees and migrants, and is working to secure additional relocations from such centres.
"Many refugees and migrants in Libya endure terrible depravations," UNHCR's Deputy Chief of Mission in Libya, Matthew Brook, said in a statement.
"They are now at grave additional risk, and must not be overlooked in the effort to get all civilians out of harm's way," he added.
UNHCR reiterated a warning that "conditions in Libya are not safe for rescued or intercepted refugees and migrants, and that these people must not be returned there."