"If you go down there you will meet young men with guns," said one of the Libyan government minders. "Please be careful," he warned.

The crossing from the territory controlled by the regime of Colonel Gaddafi to rebel-held land was a short walk, as unexpected as it was bizarre.

Bizarre, because we had been delivered to the edge of the city of Zawiyah by Gaddafi's men, who were supposed to be showing us how far their leader's writ still extended. Instead they let us out of our cars and made no effort to prevent us crossing to the other side.

The "down there" mentioned by the minder was a broad boulevard with barricades across the street. A man with a machine gun came out of a door, ammunition belt across his shoulder. A half hour's drive from the centre of Tripoli and Gaddafi's control had run out. On the walls was anti-regime graffiti. Underfoot lay broken glass and bullet casings. Armed men appeared on balconies, flashing V-signs.

In the distance a crowd and flags were visible. Men waved us forward. A short walk brought into view a tank flying the rebels' tricolour and an anti-aircraft gun mounted on a pick-up.

Some of the crowd had shotguns and hunting rifles. Others had AK-47s. In a little square overlooked by the burned-out building that once housed the local government and a library for studying Gaddafi's infamous Green Book, armoured vehicles blocked the entrances. Look-outs manned the roofs and the corners of Martyrs' Square.

We had crossed the line of Libya's rebellion. The minders stayed with the cars on the city's edge until it was time for us to leave. Then – extraordinarily – they came into the square to find us passing through the crowd of protesters unmolested.

Zawiyah – 30 miles from the capital – is a metaphor for Libya's current stalemate, which could itself end at any moment. For Zawiyah is surrounded by the Libyan army, which holds all the roads but yesterday did not appear to be deployed in sufficient forces to retake the city.

But, taking a broader view, it is Tripoli that is increasingly encircled by the opposition as towns across the country abandon the regime. For the moment, the opposition seems to lack the momentum to take the capital from Gaddafi's forces. But the situation remains remarkably fluid.

A man in a mix of military and civilian clothing pulled me up on to a tank whose barrel was pointing towards abandoned government positions. Tracks were still visible in the sand where armoured vehicles had once dug in. On top of the tank was Youssef Al-Araby, a middle-aged protester. "Don't believe what the army and government tells you. Zawiyah is under our control. We answer to the interim government in Benghazi," he said. A rhythmic chant drifted up from the crowd: "We are Zawiyah!"

None of this had been expected. Leaving Tripoli this morning on a tour organised by the government, it was in the understanding that we were to be shown a city still under government control. To prove it had not fallen. The minder in our car Our minder was clear about the mission: to show us that Libya had not been plunged into chaos, that it remained safe.

Six or so kilometres from Zawiyah, with the minaret of its mosque just visible in the distance, the convoy stopped. A distant pair of armoured vehicles was pointed out. We were told it was the last line of government forces. Two men leaving the town in a black car stopped to reinforce the government view – that those in the town were foreigners, al-Qaida fighters with beards, Egyptians and Tunisians.

But the men in Zawiyah were not foreigners, or drugged – as Gaddafi had previously claimed. Nor were they bearded Islamists or even rebels from outside. Instead, they were the town's people. There were doctors and engineers, teachers, local youths and old men all anxious to speak, although many of them still fearful that the army – whose nearest positions were only two kilometres away – would try to enter Zawiyah again.

In a small mosque off the main square, locals led us into a small storeroom to show off two captured teenage soldiers, one whose family had come from Chad.

Terrified, the boys were led out of the room, one with a dressing on a face wound. We were told they were being handed over to one of the boys' fathers.

Youssef Mustapha, a doctor who had been working at the aid station, said he believed 24 people had died in the fighting in this city, which began last Thursday night and continued for almost four days.

"We saw all kinds of injuries," he said. "People shot in the head and neck. Shotgun and rifle wounds and injuries caused by heavy calibre weapons. The firing always came from the south and east. Have you seen the graves?"

These are in the centre of Martyrs Square. Those killed in the fighting are now buried there and a pair of open graves waited to be filled.

Ghari Ahmed, a computer engineer was worried about the soldiers outside: "They control all of the main roads into city," he explained. "Villagers from around the town want to come in, but the army is blocking them. I am afraid they will try to attack again."

What Zawiyah means for Tripoli's future, and that of Gaddafi and his family, is unclear. Despite its proximity to Libya's capital, it was a different scene from Tripoli, where tanks and checkpoints guarded the main highways into the city but where traffic seemed normal.

What was not normal were the crowds outside every shop stocking up on food, or mobbing the banks; the convoys of Chinese workers, Egyptians and Tunisians in coaches and cars laden with luggage.

Most puzzling of all is why the minders appointed by Gaddafi's regime delivered the media to an opposition-held town so close to his seat of power.

I asked one why they had taken us to Zawiyah. "We didn't want to hide anything from you," he said disarmingly. "We were told to show you everything."

Next, we were taken to a village not far from Zawiyah to see the other side of the story. Here, outside a community centre, a crowd of around a hundred mainly women and children gathered to sing and clap and chant Gaddafi's praises.

People seemed less interested in talking. Mahmoud Abed Karim, an education administrator with a green scarf tied around his head, did not want to talk. The people in Zawiyah, he explained, are all al-Qaida and there are not many of them. "They are the people who were released from Guantánamo," he added. "I hope the army retakes the town."

There was another town the government wanted us to see, a place called Salman, a little further up the coast towards Tunisia. Some cars from the village followed our convoy, chanting pro-Gaddafi slogans, honking noisily on their horns.

Which leads to a question impossible to answer in such short time. Which of the scenes is more authentic — Zawiyah or Salman?

Because the reality is that this hinterland of Tripoli and its coast – despite the bussing of regime supporters – seems yet undecided which way it will go, both sides visible, both anxious to be heard.

But what is clear is that the way it is being described – as a rebel advance towards the capital – is not quite accurate for now. Instead, the rebellions are happening town by town, coming ever closer to the centre of a country balanced on the brink.