Campaign group Amnesty International has called conditions "horrific" and "inhuman".

"These detention centres, at least some of them, they work on a business model that involves smugglers, traffickers, sometimes forced labour," the UN refugee agency's top official in Libya, Jean-Paul Cavalieri, told the BBC.

Media captionMore than 500,000 migrants and refugees are estimated to be trapped in Libya

It is believed there are 12 detention centres in western Libya nominally run by the UN-recognised government in Tripoli.

Libya's plans to close three of the centres follows criticism that migrants were being returned to Tajoura after it was hit by a deadly missile attack in July.

That "outrageous" attack could amount to a war crime, said the UN's Libya envoy Ghassan Salamé and top human rights official Michelle Bachelet.

But the UN Security Council failed to condemn it after the US declined to endorse a joint statement, according to diplomats.

Tajoura Detention Centre is close to the capital, Tripoli, where there is ongoing fighting between the UN-recognised government and the Benghazi-based Libyan National Army which has vowed to take over the city.

Image copyrightAFPImage caption
These men survived a missile attack on the Tajoura Detention Centre in July

Only last week, 150 migrants drowned after they left Libya for Italy.

This was the largest loss of life in the Mediterranean Sea this year.

On Thursday, 52 migrants including 16 women and two babies were rescued from a ship that was in danger of sinking halfway between Libya and Italy.

Spanish authorities have previously warned the charity which conducted the rescue, called Proactiva Open Arms, to stop its search and rescue missions of face fines of up to 900,000 euro ($999,000; £825,000).