A CLUTCH of archaeologists sits in a freshly upholstered auditorium near the Roman amphitheatre in Leptis Magna to learn how to use a global positioning system, something restricted to the security forces under Colonel Muammar Qaddafi. “Take a picture, then note the co-ordinates,” says an instructor, showing slides of the ruins (pictured above).

The country and the government apparatus left behind by the erratic dictator, who had run the show for 42 years, were almost as decrepit as these relics of Rome. To ensure that not the slightest whiff of dissent could exist, institutions and even state bodies were never allowed to grow. Political parties were banned. Yet since the colonel’s death in October last year at the hands of rebel fighters, Libya has not only held national elections, followed a fortnight ago by the presentation of a diverse government, albeit that not all of its members have been endorsed. It has also started to build a new system of civil administration that may one day form the backbone of a law-abiding and prosperous society.

Fears—especially in the West—that extreme Islamists are spoiling Libya’s chances of creating a peaceful democracy grew in September, after the American ambassador and three fellow American diplomats were killed in an attack on the American consulate in Benghazi, Libya’s second city. In the heat of the American presidential election, Barack Obama was blamed for allegedly letting al-Qaeda back into the Libyan arena.

But on the ground, the picture, though far from uniformly rosy, is more hopeful. Many of the new state structures and services, including archaeological conservation in Leptis Magna, are being created from the bottom up rather than handed down by a central government that is still only embryonic. The new powers in the land are council leaders, a sort of cross between mayors and regional governors. Some are doing well. Most took part in the rebellion, often as administrators rather than fighters. Salim Betamal in Misrata and Abdulalli Abu Saif in Brega were academics who, as the rebellion erupted, co-ordinated civilian dissent. Ali Thow Labaz in Sirte was an oil executive who became a strategist for the rebels. Masoud Ahmida in Ajdabiah was a dentist who then managed a field hospital.

Each in his own way is trying to make up for decades of neglect during which Qaddafi concentrated resources in Tripoli, the capital. “The farther you move away from Tripoli,” says a Western diplomat, “the less of a state you see.” But that is changing. Regional structures are taking shape. Rickety they may be, but they increasingly trump those in the capital, where political rivalries and the fear of being accused of corruption have led ministers to duck hard decisions. Some cities are creating their own economic links with the outside world. Misratans now have a range of daily flights to neighbouring countries.

Dynamic local leaders have improved services. The streets of a range of coastal towns are far cleaner than in Cairo or Tunis. Rubbish-collecting lorries and street sweepers in tidy overalls are out every morning. Hospitals have reopened. Most important for ordinary Libyans, services such as tap water and electricity—disrupted during the rebellion—are working just about everywhere. Children are back at school. In Brega and Sirte, where campuses were badly damaged, student and teacher numbers are down but universities in both towns have recently reopened. “The money to rebuild came from the central government,” says Mousa Muhammad Mousa, the new head of Sirte’s university; the city, he implies, is not being punished for its sympathy for Qaddafi.

As you travel from west to east along the coastal belt where most Libyans live, the improvements are palpable. In Misrata only the main street still shows the ravages of war, and even there new glass façades have gone up. Some 28,000 of the 40,000-odd landmines laid in Brega are said to have been removed. Only Sirte, Qaddafi’s hometown, where he was caught and killed, is still a mess, with many people still living in bombed-out ruins and shacks. Dozens of new hotels are opening across the country, their lobbies filling up with dealmakers. Cafés are opening along the coastal road.

Local government must operate in a legal vacuum until a new constitution is agreed upon, probably not before the middle of next year. In the meantime local leaders owe their legitimacy to the citizens. Misrata and Benghazi held municipal elections several months ago. Ajdabiya, which lies between the two, will follow suit by the end of the year. The people of Brega and Ras Lanuf chose their councils and leaders at public meetings. Only Sirte, the Qaddafi stronghold, remains under a forced administration, its local leaders chosen by the authorities in Tripoli. Benghazi and Derna, in the east, are still struggling to contain discontent. Jobless young people in these towns are still liable to be recruited by extremists.

Local loyalties, sharpened during the revolution, have given rise to fears that Libya could break up. Misratans, who suffered most in the war, proudly mention their hometown in almost every breath, ridiculing people from Zintan, another rebel bastion, accusing them of stealing an elephant from the Tripoli zoo during the capital’s liberation. Misratan militias recently fought a full-scale battle with rivals in Bani Walid. To ease tensions, posts in the new government have been dished out on a regional basis.

Fears of separatism may, in any case, be overblown. Family links across the sparsely populated country bind people together. Provided the country’s oil wealth is distributed, it can serve as a national glue, as it did under Qaddafi. The government is already using it to buy off people with separatist tendencies— “federalists”, as they call themselves, especially those from the east, who resent being dominated by Tripoli.

At the general election in July, federalist candidates were roundly defeated, but have won concessions in the aftermath. Easterners are likely to be over-represented in the constitution-writing body relative to the size of their population. The headquarters of the national oil company may even be brought back to Benghazi.

Another key to rebuilding the state is to foster reconciliation by accommodating the less nasty parts of the old regime. Ali Zidan, the new prime minister, is from Sirte, though he was a dissident rather than a loyalist. Mr Labaz, Sirte’s council leader, says, “They loved Qaddafi here and people cry, as everyone does when you lose a loved one, but they will forget.”

Notable figures from the old regime will be put into political quarantine for five or ten years, except for a handful who switched sides early in the revolution. The most bloodstained will be put on trial, but there is little talk of punishing people on the fringes of the old order. Civil servants and businessmen, many of whom collaborated with Qaddafi to some degree, are needed for reconstruction.

Oil production has passed its pre-war level of 1.5m barrels a day. The country’s biggest refinery, in Ras Lanuf, went back on stream two months ago and is exporting fuel again. A Russian service company has been invited back, despite Russia’s opposition to the revolution. But most foreign oil firms are treading water, since the authorities are loth to award new concessions until next year at the earliest. Meanwhile the government is priming the pump, cutting the domestic price of fuel by 25% and expanding the range of staples, such as cooking oil, sugar and tea, that it subsidises, along with rice and flour. This will cause trouble in the long term, but at least it shows that the state can make a difference.