At the beginning of the revolution, Abdullah al-Mehdi, a Libyan pilot, set up a detention centre in a former school in the town of Zintan. It held more than 100 prisoners from the Gaddafi regime. He said that after the fall of Tripoli he had handed over its running to others because of more pressing commitments. Asked where he gained permission to run his own prison, he responded, "Whose permission? There is not permission. In this war I have the permission."
Since the Gaddafi regime first began to crumble back in February, the enforcement of law and order in the liberated areas of Libya has fallen to a collection of self-appointed local councils and independent militias.
As the nation emerges from four decades of institutionalised brutality and eight months of savage civil war, this inchoate assortment has at times struggled to stop retribution attacks and prevent vigilante justice.
In Tripoli in August, there was evidence of rebel fighters summarily executing supposed mercenaries. More than a dozen bodies were discovered in the centre of the city beside one of the entrances to Gaddafi's Bab al-Aziziyah complex. Some had bound hands, others had been shot dead as they lay on beds in a makeshift hospital.
Visits to prisons in the capital in recent months have revealed hundreds of African migrant workers rounded up by the former rebels who control Tripoli. At one jail, visited by The Independent in September, guards said that more than 500 black Africans were being held on the suspicion that they might be mercenaries. Black Africans in the city said that they were afraid to go out in case of arrest.
Elsewhere, there was evidence of vigilante justice committed by the former rebels. Tawargha, where Gaddafi's soldiers staged a bloody assault on Misrata, has been ransacked and its inhabitants forced to flee.
Militias from Misrata said that the 30,000 people who once lived in Tawargha will not be allowed to return. Families of fugitives from the city had sought refuge at a roadside mosque in the desert outside Sirte, two hours drive from Tawargha. They feel they are being collectively punished for the crimes of some of their community. Towns in the Western Mountains region have also seen reprisal attacks against Gaddafi loyalists.
The treatment of Muammar Gaddafi by the band of Misrata fighters that captured, beat and killed him in his home town of Sirte last month, embarrassed many local leaders who are now seeking to improve their reputation through their more humane treatment of the recently captured Saif al-Islam, Gaddafi's favoured son.
But as Libya attempts to build new institutions from scratch, it will be a struggle to ensure justice for supporters of the former regime and rein in some of the militias that are currently running the country.