Migrants in Libya are suffering consistent and widespread abuse, including arbitrary detention, forced labour, rape and torture, a United Nations report said on Tuesday.
Record numbers of migrants, mostly from sub-Saharan Africa, have been trying to reach Europe via Libya, usually in flimsy inflatable boats provided by smugglers.
Armed groups have taken effective control of official detention centres for migrants amid the political chaos that now reigns in Libya and they also run their own centres, competing and cooperating with criminal gangs and smugglers.
"The situation of migrants in Libya is a human rights crisis. The breakdown in the justice system has led to a state of impunity, in which armed groups, criminal gangs, smugglers and traffickers control the flow of migrants through the country," the UN report said.
"The United Nations Support Mission in Libya (UNSMIL) has also received credible information that some members of state institutions and some local officials have participated in the smuggling and trafficking process," it added.
Libyan officials were not immediately available to comment, but in the past have complained of being overwhelmed by migrant flows and of lacking the resources to cope.
The report said migrants were frequently bought and sold and were forced to work to pay for their onward journey, while smugglers and traffickers extort extra money from families through a complex system of money transfers.
Some Sudanese women were advised to take a three-month contraceptive injection before travelling to Libya because of the expectation they could be raped, it said.
A 16-year-old boy from Senegal detained in the southern city of Sabha was quoted as saying: "The women and the very young girls are raped and if they resist, they are beaten and threatened with guns."
Infectious diseases have spread in a number of centres, where migrants are packed into rooms without sufficient space to lie down and are forced to openly defecate and urinate in their cells, the report said.
The report also listed alleged abuses by Libya's coastguard, which sometimes intercepts migrant boats before they reach international waters, where they can be picked up by European rescue ships.
Between 1 January and 22 November, 168,542 migrants arrived in Italy from Libya, and 4,164 are known to have died at sea.
The UN report urged Libyan authorities to immediately release the most vulnerable migrants, to provide protection from abuse and to prosecute human trafficking and smuggling offences.
It also urged the European Union to "further evaluate" a training programme for the Libyan coastguard launched this year "to ensure that its vetting procedures are stringent and its human rights component is comprehensive".