The EU and its member states are complicit in the suffering of refugees and migrants stuck in Libya.

“In prison, they would hit us often,” said Ousman who spent five months in a Tripoli detention centre in 2016. “They killed many boys. I saw many people dying in prison, either because they fell sick or were beaten.”

Ousman is just one of hundreds of thousands of refugees and migrants who have braved the journey across Africa to Libya and just one of tens of thousands who have ended up caught in a complex web of abuse and extortion.

Refugees and migrants are routinely exposed to human rights violations committed by Libyan officials and security forces and abuses at the hands of armed groups and criminal gangs, who are often working in close cooperation and to mutual financial advantage. In a lawless country, refugees and migrants have become a resource to be exploited – a commodity around which an entire industry has grown, as the shocking footage of an apparent slave auction aired by CNN last month highlighted.

From the reaction of world leaders to that grainy footage, one would be forgiven for thinking that this story is a new one and that the problem is one of Africa’s own making. But nothing could be further from the truth.

The European Union, its member states – and Italy, in particular – have pursued their own goal of restricting the flow of refugees and migrants across the Mediterranean, with little thought, or seemingly care, for the consequences for those trapped in Libya as a result. They have entered into a string of cooperation agreements with Libyan authorities responsible for grave human rights violations, in particular, the Libyan Coast Guard (LCG) and the General Directorate for Combating Illegal Migration (DCIM).

On the face of it, these deals drawn up to increase their capacity to tackle smugglers, carry out search and rescue operations and prevent irregular departures have been successful. The number of arrivals in Italy fell by 67 percent between July and November 2017, compared with the same period in the previous year, and deaths at sea have been reduced commensurately. But EU countries should not feign shock or outrage when the human cost of these deals is laid bare.

EU and Italian officials cannot plausibly claim to be unaware of the grave violations being committed by some of the detention officials and LCG agents with whom they are so assiduously cooperating. Nor can they credibly claim to have insisted on key rights protection mechanisms and guarantees from their Libyan counterparts. They are, as a result, complicit in these abuses and in breach of their own human rights obligations.

The criminalisation of irregular entry under Libyan law, coupled with the absence of any legislation or practical infrastructure for the protection of asylum seekers and victims of trafficking, has resulted in mass, arbitrary and indefinite detention becoming the primary migration management system in the country.

Refugees and migrants intercepted by the LCG are sent to DCIM detention centres where they endure horrific treatment. Up to 20,000 people currently remain contained in these overcrowded, unsanitary detention centres. Migrants and refugees we interviewed described abuse they had been subjected to or they had witnessed, including arbitrary detention, torture, forced labour, extortion, and unlawful killings, at the hands of the authorities, traffickers, armed groups and militias alike.

Migrants and refugees are caught in a soul-destroying cycle of exploitation to which collusion between guards, smugglers and the LCG consigns them. Guards at the detention centres torture them to extort money. If they are able to pay they are released. They can also be passed onto smugglers who can secure their departure from Libya in cooperation with the LCG. Agreements between the LCG and smugglers are signalled by markings on boats that allow them to pass through Libyan waters without interception, and the Coast Guard has also been known to escort boats out to international waters.

The actions of European countries are leading to increasing numbers of people being stopped or intercepted. In so doing, European governments – and again, Italy, in particular – are breaching their own international obligations and becoming complicit in the violations committed by the Libyan authorities they are sponsoring and cooperating with.

Bakary, a Gambian man, was stopped at sea by the LCG and detained in the Zawiya detention centre, northern Libya in December 2016. “The police gave me the number of a Gambian man, said if you want to pay to leave you can call him, he will help,” he said. “In the centre, they don’t give food, they beat me with a rubber hose, because they want money to release me. I still have scars”.

Ultimately, the misery of refugees and migrants in Libya is a by-product of bigger economic and political trends on the African continent and bigger flaws in Europe’s migration policies. In the absence of adequate safe, legal routes into Europe and, in light of the low prospect of being returned if found not to have a claim to protection, irregular journeys will continue to be seen both as the only choice and, ultimately, a rational choice by the ambitious and the persecuted.

This play of forces can only be addressed by increasing the number of safe and legal avenues of entry to – and return from – European countries. It cannot sustainably and conscionably be addressed by enlisting the services of corrupt and abusive actors in transit countries to interrupt routes midway, without regard for how they do it, or the impact on those trapped as a result.

There are no quick fixes to this complex crisis, but it is essential that the aims and nature of European cooperation with Libya are rethought, to end this unconscionable collusion in human suffering.

The views expressed in this article are the author’s own and do not necessarily reflect Al Jazeera’s editorial policy.