They trekked through the Sahara in hope of crossing the Mediterranean to a better life in Europe but instead ended up in squalid detention centers and are now engulfed by war.
Thousands of African and Syrian migrants and refugees are trapped in Tripoli as a battle for the city draws closer.
The United Nations wants to move them urgently to safety, but this week only managed to relocate 150 to a protected facility with proper shelter, food and space for children Reuters reported.
So desperate is the situation that one detention center manager said he flung open the doors as fighting drew near.
“They can hear the clashes. And many are really scared,” UNHCR spokesman Babar Baloch said of the migrants.
They are crammed into disused warehouses, hangars and prisons where armed groups with no experience of handling refugees guard them, say witnesses and rights reports.
On the northern edge of Africa with a long Mediterranean coastline, Libya hosts more than 700,000 people who have fled their homelands, often trekking through the desert in pursuit of their dream of crossing to a better life in Europe.
About 7,000 of them are in detention centers mostly in Tripoli where conditions were awful even before they began hearing gunfire and shells as eastern forces approached a week ago.
Sleeping shoulder-to-shoulder, sometimes under steel rooves in baking heat and without proper food, water or medical assistance, the detainees wait for a visit by international organizations or the chance of a labouring job, according to visitors, rights groups and UN officials.
They are seldom allowed out for fresh air, and sometimes given just one meal a day, of pasta or bread, the sources said.
Many of the detainees were captured on arrival through the Sahara or forcibly returned by patrols stopping their flimsy vessels in the Mediterranean.
According to one UN report, last December, migrants and refugees in Libya suffered a “terrible litany of violations” by a combination of state officials, armed groups and traffickers. “These include unlawful killings, torture, arbitrary detention, gang rape, slavery, forced labour and extortion,” it said.
A study last month by the Women’s Refugee Commission, a US-based charity, said refugees and migrants trying to reach Italy through Libya were victims of horrific sexual violence.
The abuse was commonplace along routes through North Africa: at border crossings and checkpoints, during random stops by armed groups, and when migrants were kidnapped and held for ransom, said the report, titled “More Than One Million Pains”.