The military council of the Freemen of Libya Brigade sat around a table in an abandoned compound in Tripoli. Sunk deep into leather chairs designed for more prosperous times, they were contemplating the fate of a load of "cargo" they were about to receive.

"We have a big cargo coming. We need a big car," said Essam, jovial with a shaved head and a long goatee.

He was the only proper "revolutionary" on the council, having smuggled weapons into Tripoli by sea during the uprising, fought in the western mountains and led a small unit in the battle to liberate Tripoli in the final days before the collapse of the regime.

"Take the pick-up truck," said a man with crinkly hair and a thin moustache. He was a former general in the internal security police. He had defected to the rebel cause in June, he said.

"It's a lot of cargo, effendi," objected Essam. "Why don't they take the prison truck?" suggested the third man, a former intelligence officer.

"Take the prison truck but make sure to send a car filled with guards," said the fourth, a former security officer who always carried a pile of papers that gave him the look of a maths teacher. The big prison truck wasn't ready, so the men finally agreed on the pick-up truck.

The four were members of one of the many rebel military councils that have sprung up all over Tripoli since it fell.

They were busying themselves with detaining former members of the Gaddafi regime, collecting weapons from his sympathisers, providing security and running their own jail and justice system. The council members spent hours every day meeting people who came with grievances against former militiamen or security officers.

They issued warrants and dispatched teams to apprehend the wanted men, and ran a well-stocked jail. There was also a resident prosecutor whose job was to question suspects, order their release or extend the detention time.

"Of course, if they are regime criminals, when you ask them about their crimes, they will deny them," said the man who looked like a maths teacher. "We have to use some pressure on them to make them confess." After the meeting, Essam briefed his soldiers.

Among them were experienced fighters, a driver, a mechanical engineer, an oil engineer. The rest consisted of young men in brand new fatigues and bandanas. They climbed into two pick-up trucks, one mounted with a heavy machine gun. I sat next to Essam in a truck that was mounted with an iron box with only a small grille for ventilation. This truck was for the "cargo".

We drove to Abu Salim in southern Tripoli, a poor neighbourhood of low-rise, state housing apartment buildings, painted in beige and revolutionary green, which the rebels accuse of being pro-Gaddafi. Almost every other building was pockmarked with heavy machine gun bullets. Some of the apartments were burnt and gutted, charred furniture jutting out of the windows. When we arrived rebels had sealed off the area by parking their war wagons in the middle of streets. A rebel car with two loudspeakers passed up and down the main street broadcasting revolutionary songs. The plan was simple, Essam said. Gaddafi had distributed a lot of guns to the people of this neighbourhood. The rebels would go from house to house, search for weapons and detain wanted fugitives.

Three units were to conduct this operation, one from Misrata, one from Essam's Freemen of Libya unit, and the local rebel military council of Abu Salim. The Misratans, experienced and well-equipped, had a reputation as ruthless fighters who didn't trust anyone else. Essam's unit respected them but didn't really like them, and both the Misratans and the Freemen mistrusted the local rebels of Abu Salim. "They became rebels after Tripoli was liberated," said one of Essam's men, smirking.

There was a commotion among the fighters when we arrived after a fighter from the Freemen of Libya had attacked a Misratan fighter. The Misratan, thin, bearded and missing his front teeth, was wearing a military jacket with the rank of colonel.

The Freeman said it was the rank of Gaddafi, and as such it was an insult to the revolution. The Misratan insisted on wearing it and more fighters were joining the fray. Essam stopped the possible brawl by thrusting his massive belly between the factions. He shouted at his men to gather under a faraway building. They stood around him like ducklings, filled with awe and admiration.

"I want you to split into three groups: each group take a separate building," he said.

The fighters shouted a rebel war cry and ran with their guns. Essam followed with his pistol drawn, leading three teenage fighters into one of the buildings. In the dark and filthy entrance of the building, one fighter stood behind the door pointing his gun at the hostile neighbourhood outside, while Essam and the others climbed the stairs. There was a smell of burnt cooking oil.

The fighters banged on the door of the first apartment. A teenage boy opened it. The fighters did not look much older than him. "Do you have weapons?" shouted the fighters at the same time.

"No."

"How's that possible? You all took weapons from the brigades."

"No, we didn't," replied the boy.

"You did. You'd better bring out the weapons and no one will harm you. If we get in then we'll rip up the house." A frail old woman in a white headscarf that covered her shoulders came to the door to ask what was happening. "They want to search the house for weapons," she was told.

"My boys," said the woman. "We couldn't believe it when we got rid of Gaddafi, who used to send his men knocking at doors to terrorise us. Now you are doing the same."

"We are not the same," thundered Essam. "We are not Gaddafi's men. We don't kill and torture, we ask politely. If you have no weapons then who is shooting at us? You people of Abu Salim are all pro-Gaddafi. Your sons, where are they? Why are they hiding?"

The young fighters searched the flat but found nothing. They took the boy's mobile from him "to look for suspicious numbers" and moved on to the second flat. Here two men opened the door. The same conversation took place. A search turned up a bayonet sheath.

"Where is the gun?" asked Essam.

"No gun," replied one of the flat's occupants. "Just this. A friend gave me the knife. I threw it away." The fighters grabbed the man and dragged him downstairs, pushing him with the muzzle of a gun. They put him in the metal box in the back of the pickup and shot the bolt.

Then someone fired into the air.

Like cats hearing the sound of a bird, the fighters stood tensely, straining their ears. Then one by one, they started firing their guns, a staccato at first then cascading into a monsoon of bullets. The teenage fighters ran to hide behind the buildings, sticking their guns from around a corner and firing. The more experienced fighters stood in the middle of the street and fired.

Everyone was shooting in the direction of an imagined enemy somewhere in the near distance. The Freemen were squeezed between the Misratans and Abu Salim rebels, the Misratan bullets were whizzing close by, while both Misratans and the Freemen bullets were landing near the Abu Salim lot.

Essam knew it was just a matter of time before a real battle between the three groups started. He walked in the middle of the street and raised his arms, shouting: "Stop, stop". His voice was lost in the cacophony of bullets but his big body did the work and gradually the firing subsided.

Someone shouted "sniper" and pointed at the first building in the street. A dozen men ran towards it.

A few minutes later they emerged dragging a boy. Two men squeezed his neck in a head lock while the rest kicked and punched him. More men joined the frenzy. They dragged him into a car and the fighters pushed and shoved each other to squeeze through the door and attack the boy, shouting insults. "Gaddafi dog", "son of a whore" ... The boy lay there taking the punishment. He didn't cry or shout. Someone put a small video camera in front of his face and asked him why he fought for Gaddafi.

The father of the boy, a short, fat man, emerged panting from the building. "Take me with him," he pleaded. He tried to get into the car but the fighters were still crowding around the door trying to land blows on the boy. No one paid him any attention. Eventually he was allowed to go into the metal box on the back of Essam's pickup.

The fighters resumed the search for suspects. First they brought three black men. They were apparently all Libyans but the rebels said they might be mercenaries with fake ID cards.

Then a half-blind Tunisian was brought in. They had found the sights of a mortar at his house. "I was trying to sell it," said the Tunisian meekly. "I can't even see."

"We will make you see when we get you to jail," said a fighter. The box was filling up. It stood in the hot sun and the prisoners were making faint complaining noises. As we drove around the neighbourhood, the "cargo" banged against the hot metal shell of the box in the back every time Essam swerved violently around the narrow streets.

Almost all of Essam's men had spent time in Gaddafi's prisons. Many of them had told me harrowing stories about tiny airless cells and the torture inflicted on them.

We parked at another street. A woman in a black headscarf and a black dress shouted at Essam and his men from her first floor window: "You are not different from that dog Gaddafi. You are all the same. We are tired of this."

A girl dragged her inside and shut the window. A hostile crowd of people was gathering now. It was 4pm.

Thirteen men piled into the iron box were knocking at its sides, saying they couldn't breathe. There were confiscated weapons stashed in the rebel pickup, along with mobile phones. A whole neighbourhood that might have been sympathetic to Gaddafi had now become entrenched in its hostility to the rebels. We drove back to the company compound where the "cargo" was locked up in a cell.

"The people of Abu Salim were not terrorised by the gunmen sweeping through the neighbourhood or because there was shooting," a doctor who worked in Abu Saleem hospital later told me. "It was because of the arbitrary nature of the arrest. You don't know who or when you will be arrested. You can be arrested any time for any reason or even without a reason.

"This is what created the fear in Gaddafi's Libya, Saddam's Iraq and in Syria now. It is sad to see this happening in our revolutionary Libya."

A few days later I stood next to Abu Baker, a rebel commander in Tajoura. He was fat and long-bearded and very funny and energetic: he jumped from one leg to the other all the time. He was the neighbourhood football cheerleader; he used his network of football contacts to organise the resistance to Gaddafi's police and security forces. He stood manning a checkpoint at the main street in Tajoura that was also an exit point from Tripoli on the coastal road.

He stopped the small mini vans and looked inside, and randomly picked people for questioning. "You, and you and you." He pointed at three men, one sitting in the first seat and two in the back row. One of the back-row guys produced a rebel card; the other two were pulled out of the car.

Surrounded by his gunmen he took the two men to a nearby prefabricated cabin. "I know you both were soldiers for Gaddafi, hand your weapons and you are free to go," he said. One agreed. He called his family to bring him a gun so he could hand it to Abu Baker and get released.

The other said he had no gun, though he admitted he was a conscripted soldier few years ago. He was handcuffed and pushed down on his knees, Abu Baker towering over him. A setting sun filled the room with warm orange light.

"My son, give me your weapon," Abu Baker said.

"I don't have one," the young man replied.

Abu Baker slapped him hard on his cheek; the boy's eyes filled with tears. "See what happens when you say no? Now stay here and think you have half an hour."

I asked Abu Baker how he knew the fighters from the civilians. He said: "From their eyes: look at him, the white of his eyes is red, that's because Gaddafi gave them pills to fight us."

The boy's eyes were crimson red as he lay on the floor, crying softly.

Guardian journalist Ghaith Abdul-Ahad was held captive in one of Gaddafi's prisons in Libya during the first few weeks of the uprising. Recently he revisited Tripoli and filed two dispatches - on meeting his former prison guard and travelling with revolutionaries in a free Libya.

Ghaith answered your questions in an online discussion live on Thursday 3 November - see some of his responses here and join the debate in comments

Ghaith Abdul-Ahad was seized by Gaddafi forces in the town of Zawiya during the first weeks of the Libyan uprising and held for two weeks. In his first dispatch from post Gaddafi Libya, he describes his return to his former cell and his encounters with his erstwhile jailers