More than 40 migrants were killed in a late night air strike on their detention centre in a Tripoli suburb blamed on Libyan strongman Khalifa Haftar, triggering international outcry at the bloodshed on Wednesday.
The strike "clearly could constitute a war crime", said UN envoy to Libya Ghassan Salame.
"It killed, by surprise, innocent people whose dire conditions forced them to be in that shelter", he added in a statement.
Bodies were strewn on the floor of the hangar, mixed with the belongings and blood-soaked clothes of migrants, an AFP photographer said.
Tuesday night's strike left a hole some three meters in diameter at the centre of the hangar, surrounded by debris ripped from the metal structure by the force of the blast.
More than 130 people were also wounded in the raid on Tajoura, the UN statement added.
An emergency services spokesman Osama Ali told AFP 120 migrants were detained in the hangar which was directly hit by the strike.
Rescuers were searching for survivors under the rubble, while dozens of ambulances rushed to the scene.
The head of the centre, Noureddine al-Grifi, said others had been wounded in a neighbouring hangar that was also damaged by the strike.
The five hangars in Tajoura held around 600 migrants and refugees, he said.
In a statement, the internationally recognised national unity government (GNA) based in Tripoli denounced the attack as a "heinous crime" and blamed it on the "war criminal Khalifa Haftar".
Haftar, who controls much of eastern and southern Libya, in early April launched an offensive to take the capital.
The GNA accused pro-Haftar forces of having carried out a "premeditated" and "precise" attack on the migrant centre.
No-one has so far claimed responsibility, but pro-Haftar media reported Tuesday night a "series of air raids" in Tripoli and Tajoura.
The suburb of Tajoura, which has several military sites belonging to pro-GNA armed groups, is regularly targeted in air raids by Haftar's forces.
"Migrants and refugees must NOT be detained; civilians must NOT be a target; Libya is NOT a safe place of return" for migrants and refugees, the head of the UN refugee agency (UNHCR), Filippo Grandi, said in a tweet.
Migrants 'at risk'
UNHCR spokesperson Charlie Yaxley told AFP in Geneva that the agency had asked to have the centre evacuated a few weeks ago after "a near miss from a similar air strike".
"We are horrified at the deaths", he said.
The centre was thought to have been used to store weapons, he added, reiterating "that using civilian infrastructure like that constitutes a violation of international humanitarian law".
Doctors without Borders reacted via Twitter to the "horrifying events", saying "refugees and migrants trapped in Tripoli detention centres must be immediately evacuated".
Wracked by chaos since the 2011 uprising against dictator Moamer Kadhafi, Libya has become a major conduit for migrants seeking to reach Europe.
Italy's Foreign Minister, Enzo Moavero Milanesi, said the strike was "another tragedy that demonstrated the atrocious impact of the war on the civilian population".
Rights groups say migrants face horrifying abuses in the North African country, which remains prey to a multitude of militias vying for control of the oil-rich country.
"Refugees and migrants rescued at sea can NOT be returned to Libya, and those trapped in detention centers need to be urgently evacuated", said Lotte Leicht, European Union director at Human Rights Watch.
The plight of migrants has worsened since Haftar launched an offensive against Tripoli -- the seat of an internationally recognised unity government -- in early April.
Since then, fighting has killed more than 700 and wounded 4,000, while nearly 100,000 have been displaced, according to UN agencies.
Haftar's forces have pledged to intensify air strikes against their GNA rivals after losing a key town to unity government forces.
The two rival camps accuse each other of using foreign mercenaries and enjoying military support, especially air, from foreign powers.
The UN's mission in Libya has said around 3,500 migrants and refugees held in detention centres near the combat zone are at risk.
UN agencies and humanitarian organisations have regularly voiced their opposition to migrants arrested at sea being brought back to Libya, where they are "arbitrarily detained" or at the mercy of militias.