The International Criminal Court prosecutor has expressed alarm at the inhumane detention of thousands of vulnerable refugees and migrants in Libya and said she was examining whether an investigation could be opened into crimes against them.

Libya is the main gateway for refugees and migrants attempting to reach Europe by sea.

The UN migration agency said more than a thousand refugees and migrants have been reported dead or missing in the Mediterranean Sea this year, while an unknown number perish in the desert.

According to the International Organization for Migration, 20,000 refugees and migrants are held by criminal gangs in irregular detention centres in Libya and growing numbers of migrants are traded in what they call slave markets before being held for ransom, forced labour or sexual exploitation.

The International Criminal Court (ICC) prosecutor Fatou Bensouda told the United Nations Security Council that her office was collecting and analysing information "related to serious and widespread crimes allegedly committed against migrants attempting to transit through Libya".

"I take this opportunity before the council to declare that my office is carefully examining the feasibility of opening an investigation into migrant-related crimes in Libya should the court's jurisdictional requirements be met," Bensouda said.

The Security Council asked the court in 2011 to investigate crimes committed since the start of an uprising the same year that led to the fall of leader Muammar Gaddafi.

The North African state slipped into turmoil and been riven by factional strife since then.

The ICC, which opened in 2002, has international jurisdiction to prosecute genocide, crimes against humanity and war crimes in member states or if a situation is referred by the Security Council.

The IOM recently said that hundreds of African refugees and migrants passing through Libya have been bought and sold in modern-day slave markets before being held for ransom or used as forced labour or sexual exploitation.

READ MORE: African migrants traded in Libya's 'slave markets'

People are bought for between $200 and $500 and are held on average for two to three months, Othman Belbeisi, head of the IOM's Libya mission, said in Geneva last month.

"Migrants are being sold in the market as a commodity," he said. "Selling human beings is becoming a trend among smugglers as the smuggling networks in Libya are becoming stronger and stronger."

The refugees and migrants - many from Nigeria, Senegal and The Gambia - are captured as they head north towards Libya's Mediterranean coast, where some try to catch boats for Italy.

Along the way, they are prey to an array of armed groups and people-smuggling networks that often try to extort extra money in exchange for allowing them to continue.