The UN envoy to Libya,
The men were purportedly granted conditional release last week.
Libya's judicial police said that the men were released from Tripoli's Al-Baraka prison on Thursday, a day before their bodies were found dumped in different parts of the capital.
"This crime should be thoroughly and independently investigated and perpetrators must face justice.
"I urge the relevant Libyan authorities to establish a joint national-international investigation and I will follow developments closely," Kobler said.
The attorney general in Tripoli has said that the case would be investigated. The UN-backed Government of National Accord (GNA) in Tripoli has also called for an urgent investigation into the case.
The UN said that the killings may constitute international crimes under the jurisdiction of the International Criminal Court.
The case is sensitive because the GNA arrived in March with the acquiescence of some of the armed factions that have long controlled Tripoli and acted with impunity there.
Many were originally formed of rebels who took part in the 2011 uprising that toppled Muammar Gaddafi, and presented themselves as guardians of the revolution.
The GNA was designed to replace two rival governments set up in 2014 in Tripoli and the east.
GNA says it is working to integrate armed groups in Tripoli into a national security force as it tries to ease the previous government in the capital aside.
But its critics, especially in the east, have accused it of legitimising militias operating in western Libya by seeking their cooperation and not acting quickly enough to disband them.
The eastern government, parliament and military forces all released statements on the prison killings, with the government pointing finger at "outlawed groups that control the jail".
Al–Baraka prison houses hundreds of inmates, many of whom are accused of being Gaddafi loyalists.
Last year, detainees at the jail told Human Rights Watch that prison guards frequently beat them and administered electric shocks.
Thousands of people, including women and children are detained in Libya, many of them arbitrarily, the UN said.