Half an hour's drive east of Tripoli, a solitary interim government soldier peers through binoculars, scouring Colonel Muammar al-Gaddafi's hunting ranch for signs of life. Detritus of war litters the scrub, the remains of recent fighting as Gaddafi's forces fled east from the Libyan capital to their strongholds in the centre of the country. Flies swarm around parts of bodies dismembered when a Nato bomb flattened the colonel's Moorish villa, replete with its nests for hawks. Wooden cases are strewn among the olive trees; all the boxes are empty, save two that house unused heat-seeking missiles six feet long. The cages of the predatory animals raised for hunting lie open, and the anti-Gaddafi fighter seems as concerned by their escape as by their owner's.

While the foreign media focus on catching the colonel, Libyans seem to think of him as a figure who has already passed into history. Finding the deposed despot in a country of more than 679,000 square miles is a task made all the more arduous by the insouciance that Libyans display towards the question of his whereabouts. It is striking how fast, for someone whose persona dominated Libya for four decades, he has slipped from the public consciousness. His images have long since been torn down, his Green Book aphorisms torched. No one made an effort to stage rallies marking "Fatah September" - the 42nd anniversary of his military takeover on 1 September 1969 - or responded to his plea for a million-man march on the capital. Threats to unleash stockpiles of mustard gas and the fifth column, the al-tarbur al-khamis, have come and gone without incident.

Having cried wolf once too often, Gaddafi now sees his warnings of imminent car bombings and a guerrilla "war of bees that sting" dismissed with a complacent shrug. The ubiquitous graffiti drawings of Abu Shafshoufa - meaning "Fuzzy-Wuzzy" - have reduced to a joke a dictator who kept power by terrorising his population. Of all the problems facing Libya's new order, the spectre of Gaddafi's comeback falls far down the list.

After he colonel's flight from the capital on 21 August, cautious Tripolitans dithered for a bit more than a week, and then decided that the wind was blowing firmly his successors' way. Ten days later, they partied in the streets with popcorn, paper lanterns and 30,000 new Libyan tricolours. The extent of popular participation is inspiring. Where hitherto the Great Leader was so obsessed with omnipresence that he banned soccer players from wearing their own names on their jerseys, a surfeit of new actors has stepped into the vacuum. And in a country where decision-making was routed through one man, new coping mechanisms have emerged to address the hardships caused by an absent government, a plugged-up water supply, intermittent electricity and unpaid salaries.

The sense of local ownership of the revolution is important. No one has stripped the electricity cables from pylons for their copper, as Iraqis did after the United States invaded their country and toppled Saddam Hussein. Libyans, who before the uprising depended on foreign labour, farm their own allotments, run their own shops, sweep the streets and volunteer to work as hospital nurses. Homeowners with private wells open their doors to those with none. On their own initiative, policemen in Fashloum, a working-class district in the centre of Tripoli, met in the mosque on the first Friday after Gaddafi's flight and agreed to re-establish a local force. By midday the following day, 20 policemen had reported for duty.

Residents of housing estates who rarely spoke to each other under Gaddafi have created neighbourhood councils, a combination of elders, the lijan al-sulh (traditional reconciliation committees) and the underground leadership that planned the revolt, as well as respected men from the mosque. Within a week, they were supplying better services than the city's five-star hotels. The mosque in the Hadaba quarter, a poor district of rural migrants, offered air-conditioning and so much water that it spilled into the streets. In the colonel's absence, the people of Tripoli created the very social system he had taught but never realised - a jamahiriya, a decentralised network of grass-roots, non-partisan people's committees.

820/820

Yet now that the mission of ousting the colonel is accomplished, the forces that combined to unseat him are starting to judder. The official narrative of a synchronised, three-pronged campaign called Operation Mermaid, in which local people launched their own intifada while Nato bombed a path for rebel brigades sweeping down from the mountains, no longer sounds as smooth in the retelling. Tensions are manifest in the competing accounts of how the capital shook off its shackles. Rebel fighters and local mutineers agree that Nato took a back seat - in the face of evidence of an upswing in Nato bombardments - but that is about all.

Exiles returning from US and British cities after more than a generation abroad sit in hotel corridors and describe a carefully calibrated battle plan, concocted in the command-and-control centres they established in Benghazi and the Tunisian tourist resort of Djerba. They say they ran co-ordinated operations rooms, replete with Nato staffers on the ground, including in Misurata, the coastal city besieged by Gaddafi loyalists from mid-February through to mid-May. The National Transitional Council (NTC) that has been recognised internationally as Libya's new government tells a different tale. Officials of the NTC's defence ministry, newly arrived from Benghazi, depict a relentless push from the eastern front, which, though thwarted by 12,000 Gaddafi loyalists dug in 500 miles from the capital around Brega, diverted the colonel's firepower from the west.

Berbers from the western Nafusa Mountains and Arabs from Misurata recall how they bore the brunt of four months of fighting against the colonel's militias in the west while the capital's residents waited. Down corridors established over land through the Tunisian border crossing at Dehiba, by air at a makeshift runway painted on to a straight road at ar-Rahibat on the Nafusa Plateau and by sea to Misurata, they supplied and reinforced rebel positions in the west. In and around Nalut, a mountain redoubt that played much the same role in western Libya as Beida played in the eastern Green Mountain, 2,000 rebel irregulars stood up to six brigades.

Special Forces personnel from Nato member states, Jordan and Qatar honed the skills of irregulars, while Nato fighter jets doubled as the rebel air force, bombing loyalist bases and clearing a path to the capital. Only in built-up areas on the outskirts of Tripoli did the snipers slow their assault.

“They used hapless residents as human shields," says a rebel platoon commander, Ali al-Allal. "We had 18mm-calibre guns, but had to hold fire to avoid killing civilians." In house-to-house small arms fighting, rebels captured 60 black Africans whom they identified as "mercenaries" by the ritual scars on their cheeks. "Zanga, zanga, alley by alley," the colonel had egged on his forces in the early days of the revolt. In the end it was the rebels, not the colonel, who mustered the manpower and reach to effect this strategy.

But while the incoming fighters rake the night sky with triumphal volleys from anti-aircraft guns, local people decry them as impostors. By their telling, the conquest of the capital was an act of self-liberation, an intifada launched by residents on 820/820 - 8.20pm on 20 August - or the 20th of Ramadan, the day that the Prophet is said to have liberated Mecca from unbelief. A fighter recalls how sentries shared one Kalashnikov between four, rotating guard duty every six hours­, maintaining eight shifts before the rebels arrived.

An NTC member from Tripoli claims that Operation Mermaid never happened. "Nato didn't bomb its 40 pre-designated targets, and the fighters from the mountains turned up 48 hours late," says Abdelrazak al-Radi. "By the time they arrived . . . Tripoli was a liberated city, and they could march all the way to Green Square without a fight."

Neighbourhoods that claim to have freed themselves continue to man their own checkpoints and barricades long after the fighting has moved on. Their purpose, they say, is to guard against pockets of loyalists, but few doubt that they also intend to keep out incoming anti-Gaddafi fighters. Inside these enclaves, the neighbourhood councils hold sway, re-establishing civilian life in the name of the NTC but making little if any contact with it. They run their own local police and aspire to a monopoly on the use of force by requiring that all residents license their weapons.

Mercifully free from gunfire, the celebrations in these districts have encouraged families - not only men - to come back on to the streets. Anti-Gaddafi flags at first found only at checkpoints spread to public buildings, then to private homes and cars, and finally shops nervously opening their shutters. In August, ahead of Eid ul-Fitr, the three-day feast that marks the close of Ramadan, children on Fashloum's main street painted a camel in the colours of the tricolour rebel flag before a butcher sent its blood spilling into the road.

Taking the rap

Having secured control of their residential areas, Tripolitans are beginning to reclaim public spaces, such as city squares, where the rebels pitched camp. Within a week, they had transformed the mansion of Aisha al-Gaddafi, the colonel's dyed-blonde, 35-year-old daughter, into a museum, tempting families to venture out a half-mile or so beyond Fashloum's perimeter for a glimpse. Prurient women rifled through her walk-in wardrobe and children turned her indoor swimming pool into a public bath. Two veiled physiotherapists sat on a mermaid-shaped, gold-leaf-covered couch and recited an anti-Gaddafi rap, "Muammar, You Cockroach", mocking the Gaddafi family's pretence of living in tents and collecting monthly salaries of 465 dinars (about £240).

The decorum was striking. Where Iraqis stripped the villas of Saddam Hussein's family bare of their last teaspoons, Libyans respectfully filed past the dining-room table laid with crockery for 12, as if visiting a preserved historic manor on a Sunday afternoon.

But by nightfall the fighters raced through the city centre in their vehicles bearing the names of their various militias for the men-only celebrations. Gunmen from Misurata turned the Old City's Martyrs' Square into a racetrack, spinning and careening around the Italian colonnades. Beneath white billboards pleading with rebels "in the name of the revolution" to hold their fire and banners advising that "bullets scare women and children", fighters discharged a cacophony into the night. Local people, who had tiptoed out, hurried home. Bullets fired up into the air smashed their garden coffee tables. Daybreak exposed a carpet of spent shell casings covering Martyrs' Square.

Having repulsed a 70-day siege on Misurata, Libya's third-largest city, its militiamen now stand accused of imposing their own, pinning Tripoli's residents in the suburbs while they strut in the centre. "People from Tripoli were happy when the revolutionaries first arrived in the city. But then they saw them stealing government cars and shooting rocket-propelled grenades," says al-Radi.

Into the vacuum

More than bravado and a cry for acknowledgement, the gunfire carries an implicit challenge: make room for us in the new order, or we might use the power we have to spoil. While the Misurata gunmen risked their lives for Tripoli, they resent the rebel bigwigs belatedly trickling from Benghazi into the post-conquest capital to assume control of its spoils. "We will not forget the martyrs," reads graffiti daubed on the walls.

For now, the tide seems to be with Tripoli's people. In an effort to dislodge the militiamen, they have backed efforts to stand up the interim government, slowly transferring its seat of power to Tripoli. They have acknowledged that the thin upper crust aside, maintaining the remnants of the Gaddafi regime provides the fastest route to resume normality and civilian rule, and forestall the militarisation and protection rackets that filled the vacuum in Benghazi. The continued leadership of Mustafa Abdel Jalil, who until February was Gaddafi's justice minister, and Mahmoud Jibril, who was in charge of the state-run economic think tank in Tripoli, has calmed fears among the city's bureaucrats and merchants of an upheaval that could sweep them aside. At the NTC's invitation, many of Gaddafi's civil servants joined celebrations and morning prayers on the first day of Eid ul-Fitr, replacing the militiamen in Martyrs' Square.

A government stabilisation plan lays out the extent to which the Jibril government intends to keep the old order. Crafted by a cousin of Jibril's, Arif Nayid, the 70-page plan offers an antidote to Paul Bremer's de-Ba'athification, which gutted post-Saddam Iraq of its state machinery and is widely derided for turning Iraq's middle classes against the US-led occupation. In its mission statement, the plan says it seeks to "incorporate lessons and best practices from Iraq". It opposes the expulsion of "everyone associated with the previous regime . . . and the type of sweeping vetting done in Iraq". It concludes that "the main threat to stability is from those who stand to lose the most".

A blueprint crafted by the opposition is one thing; implementation is another. While all pay lip-service to righting the wrongs of Iraq's post-Saddam reconstruction, some fear Libya's interim government will veer too far the other way. With Gaddafi gone, the restoration of the old order directly threatens rebel hopes of upward mobility and a partial share of the spoils.

Militiamen still hold plenty of real estate, including Gaddafi's farms, and Tripoli's port and central bank. Others are entrenching their presence as protection squads, not least for the satellite network al-Jazeera. And they are rapidly acquiring allies in groups with similar vested interests - long-exiled Libyans anxious that the new order make room for them and Islamists seeking to move on from what they regard as Gaddafi's , the pre-Islamic age of ignorance. All three - the militiamen, the exiles and the Islamists - argue that the old state's institutions were as mad as the colonel, and that the state should be rebuilt from scratch.

To this end, rebel commanders, prominent Islamists and exiles on the NTC speak of growing unease with Jibril's government. Some openly call for the NTC to dismiss Jibril for being too compromised by his association with the old order. Ismail al-Salabi, an Islamist militia leader in Benghazi, told Reuters this month: "The . . . executive committee is no longer required because they are remnants of the old regime. They should all resign, starting from the head of the pyramid all the way down." Mustafa Abdel Jalil, for his part, has said that transitional justice in Libya should spare no one scrutiny, including him. Anti-Gaddafi fighters and Islamists are sceptical. "The interim government should not be from the regime, period," says Alamin Belhadj, an Islamist on the NTC.

Public recognition

The scrapping for dominance has already claimed its first blood. In July, the rebel commander Abdel-Fattah Younes was summoned for questioning by the NTC on suspicion of being too close to his former boss, Gaddafi. "We had reports he was deliberately frustrating the advance," says an Islamist member of the NTC. "He had thousands of weapons and uniforms that he was failing to distribute to rebels." No sooner had the summons been issued than Younes was killed, allegedly by Salabi's militia.

Will the militarisation and zeal for a new order torpedo the effort to restore civilian rule, and crush Tripoli's remarkable display of civic duty following Gaddafi's fall? Not necessarily. After four decades in which only one family received public recognition ("God, Muammar and Libya alone!" was an official slogan), the proliferation of actors could yet act as a catalyst for participatory politics, rather than a hindrance to it. Libyans could yet turn to a democratic framework to balance the country's multiple regional and ideological allegiances. Many western liberal democracies, not least the US, have emerged out of internal wars.

As the social space least contaminated by Gaddafi, Tripoli's mosques have played a crucial role in the rapid restoration of order. From the first nights of victory, preachers broadcast calls for the militiamen to stop firing in the air and register looted weapons with the local NTC office. In many districts, the mosque has become the local seat of government, as well as the source of water and, thanks to alms collection, welfare. Armed Islamist militias have lent their forces to propping up central control. Abdel Hakim Belhadj - a veteran of the Afghan jihad and its local offshoot, the Libyan Islamic Fighting Group, which tried to assassinate Gaddafi a dozen times - is the military commander of Tripoli.

Belhadj's deputy, Mehdi Herati, was a fellow brigade commander in the western mountains who, before the uprising, joined Turkish Islamists in the flotilla seeking to puncture Israel's siege of the Gaza Strip and its rulers, Hamas. Both claim to have forged a relationship with western advisers and allayed their fears of the emergence of a new al-Qaeda base in the southern Mediterranean.

For now, such is the groundswell of euphoria that Tripolitans would welcome any civilian alternative to the colonel. But the NTC cannot count on the benefit of the doubt enduring indefinitely. Already a cash shortage threatens to turn disgruntled citizens against the new rulers. No sooner had the NTC reopened the banks than it had to despatch armed guards to their doors, fingers on triggers, to contain public-sector workers flustered that reports of salary payments - unpaid for months - were false.

The Paris conference on 1 September authorised the release of $15bn of frozen Gaddafi regime funds (about 10 per cent of the total) to the NTC, which should cover the government's salary and fuel costs for a year, but will leave little for an urgently needed disarmament, demobilisation and reintegration programme. Moreover, as finances and oil revenues come back on stream (the Malita gas line to Italy is already partly reopened), the battle for control of them could intensify.

The edifice the incoming government is erecting also looks singularly fragile in the face of powerful centrifugal forces. So thinly staffed are its upper echelons that one foreign-policy expert visiting Tripoli likened them to a Pot­emkin village. Some ministers seem reluctant to share the decision-making powers they have acquired, betraying an unthinking patriotism that could yet sway its new masters to parrot the old rhetoric and spurn all offers of western assistance as meddling. "We don't need the World Bank," says the interim health minister, Naji Barakat, a former London exile, though he concedes that 40 per cent of the health system is not functioning. The UN is struggling to convince the police force to accept outside advice.

And the risk remains that Libya's militarisation will rub off on civilian life, leading Libyans to pursue their various goals by force of arms. Post-Gaddafi, weapons are everywhere. Berber peasants stash tanks in their farmyards. Beneath an overpass in Zawiya, high-school children rotate the turrets of the tanks they have commandeered. No sooner had the colonel fled than Tripoli's population scavenged the arms depots for self-defence. More hardware and missiles lie for the taking across the coastal plains. Six months ago, the Misuratan fighters terrorising Tripolitans were mere civilians, too - engineers, tradesmen, students, jobless youths - until conflict turned them into battle-hardened fighters.

The challenge for the leaders of the incoming order is to stop a revolution that began in violence continuing in the same way.

Nicolas Pelham is a Middle East correspondent for the Economist and author of "A New Muslim Order: Iraq and the Revival of Shia Islam" (I B Tauris, £12.95)