The incident, previously reported by Doctors Without Borders and local sources, occurred on May 23 in the town of Bani Walid, 170 kilometres (110 miles) southeast of Tripoli.
"Human traffickers in Libya reportedly killed more than a dozen people and wounded many others after a group of some 200 Eritreans, Ethiopians and Somalis, being held captive, attempted to escape," the UN refugee agency said in a statement, adding that those killed "were shot".
"The survivors spoke of torture abuse and exploitation at the hands of traffickers - some being held in captivity for up to three years," the statement added.
Bani Walid is a transit point for migrants aiming to reach Europe by boat from the coast further north.
People traffickers and kidnappers run around 20 detention centres in the town, telephoning the migrants' families to deliver ransom demands.
"This latest deadly incident demonstrates, once again, the huge challenge of providing protection to refugees in Libya, where many people fleeing war and persecution fall prey to criminal networks," UNHCR further said.