Migrants wait to be rescued by the Aquarius rescue ship run by non-governmental organisations "SOS Mediterranee" and "Medecins Sans Frontieres" in the Mediterranean Sea, 30 nautic miles from the Libyan coast, on August 2, 2017

Amnesty International on Tuesday accused European governments of "complicity" in the detention under horrific conditions of migrants in Libya, especially through their assistance to the Libyan coastguard implicated in people trafficking.

"European governments are knowingly complicit in the torture and abuse of tens of thousands of refugees and migrants detained by Libyan immigration authorities in appalling conditions in Libya," the rights group said in a report.

It accused European governments of "actively supporting a sophisticated system of abuse and exploitation of refugees and migrants by the Libyan coastguard, detention authorities and smugglers in order to prevent people from crossing the Mediterranean".

"Hundreds of thousands of refugees and migrants trapped in Libya are at the mercy of Libyan authorities, militias, armed groups and smugglers often working seamlessly together for financial gain," said John Dalhuisen, Amnesty's Europe director.

"European governments have not just been fully aware of these abuses; by actively supporting the Libyan authorities in stopping sea crossings and containing people in Libya, they are complicit in these abuses."

Dalhuisen urged European governments to "rethink their cooperation with Libya on migration and enable people to get to Europe through legal pathways, including by resettling tens of thousands of refugees".

"They must insist that the Libyan authorities end the policy and practice of arbitrary arrests and detention of refugees and migrants, immediately release all foreign nationals held in the detention centres," he said.

He charged that "by supporting Libyan authorities in trapping people in Libya... European governments have shown where their true priorities lie: namely the closure of the central Mediterranean route, with scant regard to the suffering caused".

Officials in the Libyan coastguard, trained and equipped by European governments, notably Italy, to curb the flow of migrants "are known to operate in collusion with smuggling networks and have used threats and violence against refugees and migrants", according to Amnesty which cited testimony from dozens of migrants.

Those interviewed had "described the soul-destroying cycle of exploitation to which collusion between guards, smugglers and the Libyan coastguard consigns them", it said.

Migrants whose boats have been intercepted are sent to detention centres "where they endure horrific treatment. Up to 20,000 people currently remain contained in these overcrowded, unsanitary detention centres," it said.

The Amnesty report also accused the Libyan coastguard of endangering migrants' lives and of intimidating NGOs operating in the Mediterranean on rescue missions.

It singled out a November 6 incident involving the coastguard and a German relief group, Sea-Watch, in which at least five migrants died.

The UN-backed government in Tripoli said on Saturday that Italy and Libya are to set up a joint commission in an attempt to fight back against people traffickers and tackle illegal migration.

Human-trafficking networks have flourished in the chaos that followed a NATO-backed uprising which toppled long-time Libyan dictator Moamer Kadhafi in 2011.