It is usually a place of education. But Tajura primary school has now been converted into an improvised prison – home to nearly 300 inmates.

They include 14- and 15-year-old boys, middle-aged men, and a small number of Africans from countries such as Mali and Mauritania.

The prisoners have one thing in common: they all ended up on the losing side in Libya's civil war. All are accused of fighting for Muammar Gaddafi. As the battle engulfed the suburb last week, nine miles from the centre of Tripoli along the Mediterranean, they opened fire on rebel positions from prominent seaside buildings.

"We'd been promised 700 dinars [£350]. But our commander took the money, hid his family and escaped," Ibrahim Bahsir, from Misrata, recalled unhappily. "People were shooting at us. We were on the roof of a building," he added. "Then they captured us and brought us here."

The majority of prisoners – accommodated in a spacious single room and wearing striped hospital pyjamas – denied they had anything to do with Gaddafi. "I didn't do any fighting," Hamadi Ibrahim, from Mauritania insisted. Another man, Nasar Bashir, said he had been arrested after his brother-in-law tipped off the rebels. "True, I once worked for Gaddafi's security agency. But I hated him. I resigned 15 years ago."

One of the many challenges for Libya's new provisional government is what to do with Gaddafi's foot soldiers. The National Transitional Council (NTC) has promised to set up a new legal ministry. But for the moment there are no functioning judges or courts, no way of sifting the innocent from the guilty, all in a society in which many had little choice but to collaborate with the Gaddafi regime.

Some of those in Tajura prison are still at school. They only joined Gaddafi's army in their summer holiday after TV adverts appealed for patriotic volunteers.

Ayad Khalifa, 14, – a thin figure with a shaved head – said he was from Sabha, Gaddafi's southern stronghold. He had been allowed to phone his family to tell them he was now in jail – but they hadn't answered. What did he want to do next?

"Finish studying," he said.

Another teenage Gaddafi fighter, Ramzi al-Sifal, said he enlisted in June after being promised 300 dinars. "The officers told me I was fighting al-Qaida. They said the rebels were from Egypt and Algeria, and that I had to defend my country." Ramzi was recovering from a bullet wound. "I had one month's training. Then last week I was shot."

Conditions in the temporary prison appeared good. There were toilets and washing facilities; a medical clinic across the road patched up the worst cases.

"There's no doubt the people here were with Gaddafi," Adnan Marwan, a dentist turned doctor, said. "We have people who informed for Gaddafi before the revolution. We also have Africans. Some of them speak Arabic so badly we had to find a translator."

Marwan said that in the chaotic final hours of the war, Gaddafi loyalists had conducted bloody reprisals against the local civilian population.

He said he found three bodies of prisoners who had been locked in a shipping container; all had suffocated. Another body washed up on the beach. The victim had his hands tied, and had been shot.

"Some of the people here are just children. What we need to do now is rehabilitate them, teach them right from wrong," Marwan said.

There are several other haunting massacre sites across Tripoli; bringing the perpetrators to justice is an almost impossible task.

Many were executed last Sunday or Monday as the rebels advanced into the capital and an uprising began inside it. Gaddafi loyalists shot 17 detainees held in an internal security building in the Gargur area. The victims were killed minutes before they would have been freed.

One survivor, Osama al-Swayi, told Human Rights Watch that 25 people had been held inside the prison. He said he heard the rebels shouting and expected to be released; his captors, however, ordered him and the others out of their cells and told them to lie on the floor. "I saw three dark men. One soldier gave the order: 'Just finish them off.' But I don't know who it was. There were three or four who fired at us … I was near the corner and got hit in the right hand, the right foot, and the right shoulder. In one instant they finished off all the people with me," he said.

Another 18 bodies were found rotting in a dry riverbed between Gargur and Gaddafi's shattered compound at Bab al-Aziziya – further evidence of apparent war crimes. Some 50 charred bodies were also discovered in a military camp in Tripoli held by Gaddafi's supporters.

"The evidence we have been able to gather so far strongly suggests that Gaddafi government forces went on a spate of arbitrary killing as Tripoli was falling," Sarah Leah Whitson, Human Rights Watch's North Africa director, said in a statement.

She added: "These incidents, which may represent only a fraction of the total, raise grave questions about the conduct of Gaddafi forces … If they are proven to be extrajudicial killings they are serious war crimes and those responsible should be brought to justice."