It was the moment all Libyans had waited for: the announcement that their country is totally liberated, and they can consign Muammar Gaddafi's four-decade rule to history.

But for those in Benghazi, where it all began in February, in the early days of the Arab spring, it felt especially the right moment and the right place for this historic announcement to be made.

Mustafa Abdel-Jalil, head of the ruling National Transitional Council (NTC), set the tone with a moment of prayer, a salute to those who had died to save Libya from tyranny; and then he issued a stern appeal to the happy victors to stop the dangerous practice of firing guns wildly into the air by way of celebration.

"We have all waited for this moment," Abdel-Jalil declared solemnly from a flower-bedecked podium in the city's Kish square, near to where the old regime security forces claimed their first victims and set Gaddafi's "state of the masses" on the path to destruction. "This revolution began peacefully with the demand for justice," he told the cheering crowd, "but it was met by excessive violence."

"It was terrifying at the beginning [of the uprising]," recalled Khaled Abdullah, a manager, gesturing through the hooting, gridlocked traffic on Abdel-Nasser Street in the dilapidated city centre where many buildings still show signs of damage from bullets or rocket-propelled grenades. "People were killed right here."

Thousands had begun to gather under a canopy of red, green and black revolutionary flags, hours before the liberation ceremony was due. The mood was part public holiday, part patriotic rally, part respectful mourning for those who died; as many as 30,000 in all, according to estimates by the NTC.

Soldiers in camouflage uniform, just returned from the Sirte front, some injured and some in wheelchairs, families with babies in prams, old and young, poured in a seemingly endless stream into the plaza. "It truly is a historic moment for Libya," said Omar Ismail, a business student and hoping, like many young people, for opportunities in a country emerging into freedom, blinking but delighted after 42 years of dictatorship.

"Gaddafi's gone, gone for good," one group of excited young men chanted to the rhythm of a tambourine, interrupted by more bursts of gunfire.

Fireworks and an occasional sound bomb added to the deafening cacophony. The cheers swelled as another column marched jauntily past a burnt-out secret police building and an effigy of a frizzy-haired Gaddafi – larger than life and twice as ugly – looking out to sea.

"Today is a lovely day," beamed Anwar Sharif, 50, an oil engineer who had brought his three children to the square. "In the first days of the revolution it was very frightening here, but the moment that the Nato attacks started on 19 March we knew it'd be all right in the end."

Adel, an officer with the Saiqa battalion, was convinced western intervention had been vital. "Without it, Benghazi would have seen a terrible massacre. Gaddafi's forces were very close. It was the right thing to do. Libya isn't Iraq."

Abdel-Nasser Belqasim will never forget what happened when he was one of a crowd who tried to storm the nearby Fadil barracks, where Gaddafi's son Saadi and intelligence chief Abdullah Senussi were in command. "I was throwing stones when they started shooting from the roof. The bullet hit me in the throat and came out through my chest here," he gestured, lifting his T-shirt – the scar tissue livid and stretched tightly over his ribs. It had taken two months in hospital in Benghazi, and two more in Turkey, to restore him to health. "But now Gaddafi is dead, I feel just great," he grinned.

For sales manager Abdel-Khaleq, Fatin, his unemployed graduate wife, with their shy little children Muhammad and Jana in tow, the aspiration is jobs, and better education, healthcare and social insurance. And that Libya's oil wealth will be spent on its 6.5 million people, not squandered on Gaddafi's African adventures. "We want our children's lives to be easier and freer than ours," Fatin said.

Tripoli fell to the rebels on 20 August, but the announcement of total liberation had to wait until the end of diehard loyalist resistance, first in Bani Walid, south of Tripoli, and then in the coastal city of Sirte, where, last Thursday, Gaddafi's sensational death triggered an explosion of jubilation that has yet to wane.

Abdel-Jalil and his NTC colleagues are delighted too – but they are sharply aware of the burden of rising expectations as Libyans begin a countdown to their first free elections in 50 years. Faraje al-Sayeh, the official in charge of capacity-building, remembers thinking that a real revolution had started last February as he watched the first news of violence in Benghazi on al-Jazeera. Eight months on, the challenge is to build institutions in a country that had none. "The heritage of 42 years has left a deep scar," he said, "and it will take years to heal."

In the hours before the ceremony, excitement was palpable in the NTC's headquarters, a former hotel in 1970s Jamahiriyah modernist style (all stucco, fake Corinthian columns and crystal chandeliers), where uniformed soldiers, smooth foreign diplomats, Libyan men in smart, dark suits, and the occasional headscarved woman bustled around, adding to the expectant buzz of a big day.

Naji Barakat holds the NTC health portfolio. For 20 years he lived and worked in London as a paediatric neurosurgeon, and had almost given up on his native country in late 2010, but he joined the revolution as soon as it erupted. Now, he warned, it was urgent to disarm, demobilise and reintegrate 100,000 men under arms, to promote national reconciliation, and to start reforms in education and training. "The next eight months will be crucial," Barakat said. "After that, things should settle down."

Worries lie ahead for post-Gaddafi Libya, but liberation day was a day to enjoy – and to treasure. "In Muammar's time, we always had to go to events like this, to celebrate the 1969 revolution and so on," said Wanis Agouri, a factory worker waiting in a sidestreet in a battered Fiat for his children to weave their way through the crowds after the rally.

"It was compulsory. They used to give you the day off work, and docked your pay for a month if you didn't go. So there was no choice.

"But today people want to be here, it's from the heart. That's the difference. It's a new world."