The UN has called for the dismantling of all detention centres for refugees in Libya, saying the facilities are not fit to house migrants.
The appeal comes nearly two weeks after more than 50 people were killed in an air strike on a holding facility in the Libyan capital Tripoli.
The victims were mostly Africans attempting to reach Europe on boats after fleeing poverty and conflict.
The UN refugee agency has called the facilities in the centres “awful”.
Thousands of migrants are being held in dire conditions in government-run detention centres across Libya.
The recent air strike on one of them during fighting in Tripoli has revealed how dangerous these facilities can be.
The UN refugee agency said the centres should be dismantled immediately, and their detainees freed into their surrounding communities. The agency said it is ready to help support them there.
The UN has been critical of European policies that favour returning to Libya migrants who are rescued at sea, stating that the country isn’t safe for them.
Some 120 migrants were inside a hangar at the Tajoura Detention Centre when it was hit on 3 July, with women and children among the 50 fatalities.
The UN-backed government, led by Prime Minister Fayez al-Sarraj, accused the self-styled Libyan National Army (LNA) of carrying out an air strike on the centre.
The LNA said it had attacked a pro-government camp near the centre and pro-government forces had fired shells in response, hitting the migrant centre by accident.
A UN official later said the attack could constitute a war crime.
Libya has been torn by violence and division since long-time ruler Muammar Gaddafi was deposed and killed in 2011.
UN calls for Libyan migrant detention centres to be shut}