In this showpiece city, with its wide boulevards and ornamental hedges, there were scores to be settled. Sirte was once Gaddafi's dream in the desert, the gleaming city he built next to the place of his humble birth. Today it lies in ruins, testament to the folly of the fallen leader and the vengeance of men at war.

The silken carpets and cool marble of the hotels and conference centres where he made his rambling bombastic speeches, pontificating on pan-African unity and other pet projects, are destroyed or defaced.

In the stretches of city that saw the heaviest fighting, the Mauritanian district, Area 2 and the 1 September boulevard, barely a building remains unscathed. So fire-blackened and pulverised by cannon fire are some of the now skeletal structures that they look diseased.

In a building speckled with bullet holes in District 2, two men were putting back together what had once been a shop. "People from Misrata were taking their revenge," said one of the men, who gave his name as Suliman. "They've taken everything – animals, horses, cars. They've made people get out of the cars and killed them. They killed two old men for a car."

The other, giving his name as Ibrahim, added: "They say they are looking for weapons but if they see anything they like, they take it. Sometimes they break up the furniture deliberately. Nowadays they are in power – they're the ones with the weapons. There is no law at all."

Misratans, who saw their own homes besieged and destroyed in April and May, appeared especially hungry to exact their revenge on Gaddafi's favoured city. "I ordered them to fire 106s into the city at night," confided one Misratan commander, "so as not to give them any chance to recover, so as to divide them."

The effects are visible everywhere. Many of the homes are now too damaged to be rebuilt. An abandoned bus lies shot up in the street, its windows eaten away by bullet holes. A lone man picked through the rubble but ran away when he saw that he was being watched. There are pro-Gaddafi graffiti slogans scrawled on the walls in green paint – written by the residents or the fighters who held out here – and people do not want to be seen. Bullet casings still litter the ground and abandoned shells are scattered throughout the streets.

At the centre of the city is the Ouagadougou Conference Centre, a grandiose folly built to host the pan-African summits as Gaddafi turned away from the Arab world and dreamed of a United States of Africa with Sirte as its capital. With the city under siege, it served as a fortress from where loyalist fighters held out for weeks. The domed hall has been hit by rockets. Inside, the once-lavish green marble tables have been hacked away. The walls are scrawled with graffiti. The TV screens that the rebels could not rip from the walls have been sprayed with bullets and the ground is thick with broken glass.

The battle for Sirte began in mid-September, a few weeks on from the fall of Tripoli. Brigades from Misrata were the first to join the fight, congregating on the western edge of the city. They blasted away for weeks, firing indiscriminately into all of its districts. No one ever consulted a map. The daily routine was to gather on the outer ring road, then ride forward in pick-up trucks, releasing volleys of missiles in a teeth-rattlingly show of force. The rebels rarely stopped to aim.

As the weeks wore on, they edged closer, aided by reinforcements from Benghazi who reached the eastern front in late September. With Sirte encircled, brigades began pushing into the outlying residential districts but encountered astonishing resistance. A few hundred hungry, exhausted loyalists held out against more than 20,000 well-fed rebel soldiers for more than a month.

Ambushed as they tried to escape the advanced rebel army, two men were chased into a basement and shot dead underground. Their bodies were bandaged from numerous old wounds.

As the fighting intensified, the vast majority of Sirte's residents fled. Those who stayed, the rebels reasoned, were those who loved Gaddafi. But those who did stay say they felt they didn't have a choice. "I didn't have anywhere to go," said Ramzi Mansour, who runs a café in Sirte. "This is my house. If I leave it, maybe they'd break in and steal things."

Contrary to expectations, Sirte's citizens are returning. According to Ali Turjman from the NGO Acted, 50 per cent of the city's former population of 122,000 are said to have returned. Water and electricity are coming back. "It's difficult," he conceded, "but every day is better than the one before."

Slowly, painfully, they are sweeping the streets, clearing the carpet of metal bullet casings that once covered the roads, filling the holes that pockmark every building.

But they face the continuing wrath of the Misratan fighters who destroyed their city. On 24 October, Human Rights Watch reported finding the bodies of 53 men at the Mahari Hotel, a five-star hotel once on the frontline. "We found 53 decomposing bodies, apparently Gaddafi supporters, at an abandoned hotel in Sirte, and some had their hands bound behind their backs when they were shot," said Peter Bouckaert, emergencies director at Human Rights Watch, who investigated the killings. "The evidence suggests that some of the victims were shot while being held as prisoners, when that part of Sirte was controlled by anti-Gaddafi brigades who appear to act outside the control of the National Transitional Council." Ten further corpses were found in a water reservoir.

Asked about the behaviour of the Misratan rebels, the head of the military council there, Ramadan Zarmoh, conceded that there may have been abuses. "It's possible. It's to be expected. The revolutionaries are thousands, and maybe there were a few who made mistakes."

Two months on, the bodies have been taken away from the stark lobby of the Ibn Sina Hospital, where wounded Gaddafi loyalists were treated during fighting in the city. In their place is a television screen showing shots of 360 bodies, the unknown dead from the fighting in the city. Matug Ahmed was among those watching the grim slideshow, searching for his cousin Ali Mohammed. He didn't know if he'd been killed or imprisoned.

Back at the Mahari Hotel, the swimming pools are filled with fetid water. The statues in the lobby are smashed. The layers of soundproofed glass that shielded the rooms are scattered across the floor. "It's such a waste," said Khalid, a construction worker who was surveying the ruins. "Libya is losing billions. We'll need four or five years to get back to how it was before. Not even to move forward."