Ask people in Benghazi what awaits them if Muammar Gaddafi's army fights its way back into the rebel capital and the chances are they will talk about Huda Ben Amer.

Today she is one of the Libyan dictator's most closely trusted lieutenants, but nearly three decades ago Ben Amer was a young woman in Benghazi keen to earn a name with the regime. Her moment came at the public hanging of one of Gaddafi's opponents in 1984. Ben Amer rushed forward as the unfortunate man dangled from the rope, wrapped her arms around his body and used her weight to pull down until he was dead.

That stomach-churning performance won her Gaddafi's attention, and Ben Amer rose to become powerful, rich and twice mayor of Benghazi. It also earned her the enduring hatred of many in a city long viewed by the regime as riddled with subversion, where she is spoken of with the same depth of loathing and fear as the dictator.

When the revolution erupted in Benghazi last month, a crowd descended on Ben Amer's sprawling white mansion and, on discovering that she was out of the city, burned it to the ground.

"If we lose, Huda Ben Amer will hang all of us," said Walid Malak, an engineer turned revolutionary who has armed himself with a Kalashnikov plundered from a military base abandoned by Gaddafi's forces. "Everyone in Benghazi knows it's them or us."

That refrain is increasingly heard across the capital of a revolution that for a while looked as if it might sweep Gaddafi and his regime from power within days. Now, with rebel forces in retreat and Tripoli's army moving closer by the day, the euphoria and expectation of initial uprising have given way to a grim realisation that it is the revolution which is now under threat and Benghazi may soon be fighting for its life.

The head of Libya's revolutionary council, Mustafa Abdel Jalil, warned that, if Gaddafi's forces reach the country's second-largest city, "this would mean the death of half a million".

That may be hyperbole designed to whip up international support for the rebels, but Jalal Tuwahni, a clothing shop owner who returned from self-imposed exile in the US last year, said he regards the revolution as a fight to the death: "People know if he comes back they will all die. Everybody in Benghazi has something to do with this revolution. Women went out on the streets. Their children joined the revolution. Everybody's volunteering. I never thought we had that sort of solidarity.

"Everybody is doing something. They're taking responsibility at the hospital, the water plant, the power station. People are cleaning the streets or directing traffic, even though they're not paid. A neighbour got a truck and picked up all the rubbish around here. Everybody is invested in the revolution."

The uprising was inspired in large part by the revolutions in Tunisia and Egypt and, while it has moved on since then to look increasingly like a civil war, some of the same acclamations are heard in Benghazi as in Cairo's Tahrir Square.

"The fear barrier is broken," said Salem Langhi, a Benghazi doctor who volunteered to treat rebel fighters on the frontline. "Finally people are not afraid. They want to read what they want. They want to say what they want. Every single Libyan is so surprised. We didn't know we had this in ourselves. We have discovered many things about ourselves."

Hundreds of young men, some still in their teens, have grabbed guns and made for the frontline against Gaddafi's forces. Many are ill-trained and poorly disciplined, wont to shoot randomly into the sky in frustration at bombing raids, but their courage and dedication is not in doubt.

But it has not proved enough so far to stop the advance of Gaddafi's forces and Benghazi looks woefully underdefended. The regime's army is still hundreds of miles away, but there are only two small towns and vast expanses of desert for the revolutionaries to make a stand in.

The revolutionary leadership has admitted it is outgunned and appeals for foreign help have grown increasingly loud. Disappointment has turned to anger in the face of the military reversals of recent days and the reluctance of nations with the power to do it to respond to the rebels' pleas for declaration of a no-fly zone to ground Gaddafi's bombers, and even for air strikes.

Next to the courthouse serving as the revolutionary council headquarters is a burned-out government building, licks of black from the flames still around the windows. Inside, the revolution's propagandists, mostly young men and women revelling in the wonder of suddenly being able to say out loud the life-threatening thoughts they kept to themselves for years, have let loose with markers and paper to produce a tide of slogans and caricatures pasted on walls around Benghazi. A banner inside this revolutionary hive reads: "Here we rewrite history by our blood and naked chests".

The revolutionary volunteers have churned out caricatures of Gaddafi being throttled until money pops from his throat, and of him naked and alone on a desert island with a slogan that says he is with the only friend he has in the world. Doctored pictures have him as a dog with his tongue hanging out. Another conjures up a fantasy of him under arrest by the international criminal court.

Mohammed Najem is among the poster makers. A construction company manager in more normal times, Najem has thrown himself into a revolution he describes as "beautiful".

"For 42 years you never saw the unity of the people like the last three weeks," he said. "Gaddafi made people distrust each other. There might be two brothers. One would register with Gaddafi's revolutionary committee and have opportunities. He would get land for free and a car and be very well paid. But the other brother did not want to get his hands dirty with the regime and would have nothing. They hated each other. This country is like those two brothers."

Among the posters emerging from the propaganda centre is one that says: "We are all Libyans... Everybody is watching us... Be brave... Use a nice behaviour."

Libyans are acutely aware that the view of their country overseas was shaped almost entirely by the cult of Gaddafi and the image of him as mad, unstable and a terrorist. "He made us ashamed of our country," said Iman Bugaighis, a lecturer in dentistry at the city's university, who has become the spokeswoman for the revolutionary council. "He took away our dignity. It was all about him, never about the people. He thought he was Libya. Everything was about loyalty to him. He changed the flag. It was his flag, not our flag. He changed the name of the country. He even changed the names of the months."

One of the posters on the streets uses the colours of the flag from the pre-Gaddafi era, now seen everywhere in Benghazi, to declare: "Red, White, Green, Black... We're taking Libya back."

"We were given a mask for 42 years. It was the mask of Gaddafi," said Langhi, the Benghazi doctor. "He stole all of our identities. There was only Gaddafi."

The dictator's cult has been replaced in the city by intense debate about what comes next. For the moment, Benghazi's people are doing it for themselves in the absence of any real administration. The newly established Provisional Transitional National Council of Libya is principally preoccupied with diplomatic efforts to win foreign support and establishing basic administration in the rebel-controlled areas.

It is made up of 30 representatives, some of whom it is not even prepared to name, out of fear of retribution against members of their families living in areas under Gaddafi's control. The council is headed by Mustafa Abdel Jalil, one of Gaddafi's former justice ministers. But in a country where political recognition was dangerous unless it was to serve the dictator, the other members are not well known and were chosen as representatives of the country's disparate areas and tribes, or because of their experience as lawyers or activists.

The council plans to begin drawing up a new constitution, but seems to have no longer-term vision beyond a broad commitment to a multiparty system and free elections. That has left Libyans in the liberated areas to debate whether the country should be secular or an Islamic republic, given that almost everyone is Muslim. Some point to Turkey as the example, others to Lebanon.

Each revolutionary has an idea of what change should mean. "It will be unlimited freedom of speech," said Najem. "Even if people are against the current [revolutionary] committee, they will be allowed to say what they want. Also in the years of tyranny, we lost a lot of education. They stopped teaching English in schools, we lost our medical doctors. The country has money, but doesn't have an infrastructure."

Langhi, the doctor, wants to see Libya's oil riches work for the people: "Look at the state of our hospitals when we have so much oil. People have to go to Egypt or Tunisia for operations. One of the priorities we have to discover is how to use the money for the people – health, education, housing." In a country so rich on paper, there are families in Benghazi living in containers.

Others are focused on justice for the regime's crimes. For many, the revolt was driven by a bitter family history. Najem describes how an uncle was killed by the regime in 1984 and how his father's property was seized for redistribution to Gaddafi loyalists.

At the revolutionary council headquarters, a former air force colonel said he witnessed killings by Gaddafi's regime in his home town of Darnah in 1995: "I saw seven people killed. One had his eyes plucked out. They were shot in the back. The man in charge of the group paraded the corpse through the town. They were just a few of the people he killed there, some of them from my family. We could say nothing if we didn't want to die. Now there should be justice."

There were not many illusions to be shattered by the revolution; in Benghazi, at least, people had long since ceased to believe the man they now call "the mad dog of Tripoli". But one self-delusion was blown away by the uprising. Gaddafi's most visible son, Saif al-Islam, persuaded many people, from international human rights groups to the London School of Economics, that he stood for change for the better. Many Libyans believed it, too.

"Saif was educated abroad. Young people were persuaded he was trying to reform in the face of resistance from his father and family," said Tuwahni. "People loved him, even if nothing ever happened. He was a glimpse of hope, all the kids loved him. They wanted him to be president."

But the mask was ripped away in the first days of the revolution as Saif went on TV with bloodcurdling threats of revenge against the protesters.

"Saif's speech shocked people," said Tuwahni. "He came out with his father's face. All the kids were waiting for his speech. They were expecting a lot. It was a disaster. We knew then there could be no compromise. We will have to fight until they are defeated or we are."