Libyans are pictured in front of a mural depicting a torture scene outside Tripoli's Abu Salim prison, scene of a 1996 massacre of prisoners. The prison was notorious for torture and human rights abuses during the time of Moammar Gaddafi. (Mahmud Turkia/AFP/Getty Images)

The prison is a vast, unmarked complex of beige buildings, topped with sandbags and surrounded by high, wire-rimmed walls. Most of the guards wear their beards long and unkempt in the style associated with Islamists — exactly the kind of people that Moammar Gaddafi and his intelligence chief, Abdullah al-Senussi, used to keep locked up.

But if ever there was a picture of poetic justice in post-Gaddafi Libya, this is it. The prison’s chief, Mohamed Gweider, is a former Islamist insurgent who spent more than a decade in a Libyan prison. Two of the guards who tortured him, he says, are now his prisoners, and the biggest prize is Senussi himself.

It would be “impossible’’ for Libya to send such captives abroad, Gweider said, even though Senussi and another prisoner, Saif al-Islam Gaddafi, a son of the late dictator, are being sought by the International Criminal Court for mass killings and other atrocities alleged to have taken place during Libya’s 2011 revolution.

The Libyan government has adopted the same defiant stance, vowing to try the men on Libyan soil as testament to the country’s successful transition from dictatorship to democracy. For now, the international court has suspended a demand that Gaddafi be handed over immediately, pending a decision on a legal challenge mounted by the Libyan government. But legal experts warn of potential perils if Libya and its hodgepodge of new leaders prove unwilling to comply with international law.

The role reversals in Libya that have put former prisoners, opposition leaders and outlaws into positions of power point to a vacuum that legal experts say the ICC should fill in countries such as Libya, where doubts remain about the prospect of a fair trial for suspected war criminals.

Most of Libya’s prisoners had been “held for more than a year without charge or due process rights, including judicial review and access to a lawyer,” Human Rights Watch said in its 2013 World Report, released last month. Detainees in some facilities reported “repeated torture and deaths in custody,” according to the report.

Across the country, many of the men who guard some 8,000 prisoners, seized during and after Libya’s eight-month revolution, are former rebels or former prisoners themselves. The top posts in the Libyan government and security services are peppered with former members of the Libyan Islamic Fighting Group, an extremist group that battled Moammar Gaddafi’s regime sporadically throughout the 1990s.

Former members of that extremist group have also established a new national guard, which controls at least part of the complex where Senussi is held, according to two people who have visited the facility and who spoke on the condition of anonymity because of the sensitivity of the subject. (Saif al-Islam Gaddafi, once considered his father’s heir apparent, is in another prison in the mountain town of Zintan, held by the Libyan rebels who caught him.)

‘I should be taking revenge’

Hanan Salah, a Libya researcher at Human Rights Watch who has met with Gweider and other justice and prison officials, said there is nothing inherently problematic with former fighters running Libya’s prisons. But the lack of training and vetting, to ensure that guards don’t have records of abuse, is a problem, she said.

For Gweider, like many others, the mission is personal. Gweider was arrested in 1986 on charges of conspiracy as part of an underground jihadist cell, while serving as an intelligence agent within Libya’s external security service, the spy agency headed by Senussi.

By the time he got out of Tripoli’s notorious Abu Salim prison in 1997, he said, he bore the physical and psychological scars of more than a decade of torture. His daughter didn’t recognize him, he said, and his wrists still carry the marks left by the cords that guards used to suspend him from the ceiling. But Gweider, 49, counts himself among the lucky men who survived a 1996 massacre of about 1,200 people at the prison, which Libyans believe to have been orchestrated by Senussi.

When Libyan rebels seized control of Tripoli in August 2011, Gweider joined the fight and quickly ascended through the ranks to become head of what he describes as a “VIP prison’’ on the site of a former training facility for Moammar Gaddafi’s security services. Senussi arrived five months ago, after being apprehended in Mauritania and transferred to Libyan custody.

But Gweider’s unique knowledge of the Abu Salim massacre, which he describes hour by hour based on what he says he heard and saw from his cell — including details that directly implicate Senussi — makes him a potentially valuable witness to Libyan prosecutors investigating alleged abuses under Gaddafi. It also complicates his position as Senussi’s caretaker.

Ben Emmerson, a prominent human rights lawyer hired by Senussi’s family to represent him, said the situation is outrageous. “Where in the world would you put a man in the custody of people who claim to be victims of crimes the man has committed?” said Emmerson, who is also the special rapporteur for the protection of human rights and freedoms amid the fight against terrorism under the U.N. Office of the High Commissioner for Human Rights. “No one takes the prospect of a fair trial in Libya seriously,” he said.

Emmerson said Libyan authorities have been “prevaricating and playing games” with the ICC and have no intention of turning Senussi over to The Hague. Instead, they want to see Senussi convicted and executed in Libya, he said. “The crucial prize for the Libyans is to have this man hanging at the end of a rope,” Emmerson said.

Libya wants Senussi in connection with the thousands of deaths, injuries and disappearances inflicted by Gaddafi’s forces on the civilian population during the revolution, as well as a litany of other abuses during Gaddafi’s rule.

Foreign governments are interested in Senussi, too. He is suspected of having orchestrated the 1988 bombing of Pan Am Flight 103 over Lockerbie, Scotland, which killed 270 people. France has sought Senussi’s arrest in connection with the 1989 bombing of a UTA plane. Libya’s former prime minister, Abdurrahim el-Keib, told the Guardian newspaper in Britain last year that Senussi was a “black box” of Gaddafi regime secrets.

Emmerson has not been granted access to his client, but he said he had reason to believe that Senussi has been tortured.

But Gweider said that neither Senussi nor any other man at his prison has been tortured, a fact that makes them “very, very lucky to be here,” he said.

“If you think about it logically, I should be taking revenge because 1,270 people died and many of them were my friends,” he said, referring to the massacre at Abu Salim. “But I didn’t take revenge.” He said his prisoners have access to a doctor 24 hours a day and eat “the same food” as the guards.

At other prisons across the country, some prisoners have languished for up to two years without trial, according to Libya’s justice minister, Salah Marghani. Investigations are slow, prosecutors are scarce and willing defense lawyers are even scarcer, raising doubts among international rights groups about the likelihood of due process.

And, Marghani said, “unfortunately, the culture of torture has continued after the revolution.” Libya “has a problem,” he added. “We have prisons that were spinning out of control. But we are working on changing that.”

Libyan officials, including Marghani, a veteran human rights activist, say that trying the men at home — and doing it fairly — carries symbolic value for a nation struggling to shrug off decades of authoritarian rule and find new recognition among the world’s democratic states.

“There are many shortcomings with our system,” Marghani said. “But eventually, we will get the proper system in place.” Torture will be stamped out. Prisons will come under Justice Ministry control. Men such as Gweider will be trained and vetted, he said.

Awaiting evidence

In January, a court in Zintan held a hearing for Saif al-Islam Gaddafi on charges that he violated Libyan national security by interacting inappropriately with ICC lawyers during a visit in June. Gaddafi’s guards accused the ICC of passing documents to Gaddafi, and they detained ICC lawyer Melinda Taylor in Zintan for three weeks — an episode that rights lawyers later pointed to as evidence that Libya is unwilling to respect international law.

Last month, Libyan authorities submitted the last bundle of paperwork in their challenge to the international court, making the case for trying Gaddafi at home. Fadi El Abdallah, a spokesman for the ICC, said the court would respond in due course. Libya says it has plans to challenge Senussi’s extradition order, but it has not yet done so.

If the court upholds the orders, however, Tripoli would be required to hand over the two men. And if Tripoli refuses, the court could refer the cases to the U.N. Security Council.

But many Libyans, including Gweider, are holding firm. Although Senussi and Gaddafi might ultimately be executed, their trials would at least be “transparent,” Gweider said, unlike any trial under Moammar Gaddafi.

The two men are Libya’s war criminals, he said, and Libya will not surrender them for trials abroad, regardless of the country’s current state. “The political leadership in Tripoli,” he said, “will never consider it.”

Ayman al-Kekly contributed to this report.