A rebel steps on a poster of Libya's leader Muammar Gaddafi at Rixos hotel in Tripoli
A rebel steps on a poster of Libya's leader Muammar Gaddafi at Rixos hotel, after gunmen released foreigners, in Tripoli August 24, 2011. At Tripoli's Rixos hotel where loyalist gunmen had been preventing nearly 40 foreigners, mostly journalists, from leaving, gunmen relented on Wednesday and let them go. Reuters

Fugitive strongman Muammar Gaddafi taunted his Libyan enemies and their Western backers from his hiding place as NATO targeted his hometown and rebels announced a move to govern the country from Tripoli.

Rumours of Gaddafi or his sons being cornered, even sighted, swirled among excitable rebel fighters engaged in heavy machinegun and rocket exchanges. But even after his compound was overrun on Tuesday, hopes of a swift end to six months of war were still being frustrated by fierce rearguard actions.

Western powers demanded Gaddafi's surrender and worked to help the opposition start developing the trappings of government and bureaucracy lacking in the oil-producing state that has been ruled by an eccentric personality cult for the past 42 years.

The United States and South Africa struck a deal to allow the release of $1.5 billion in frozen funds for humanitarian aid and other civilian needs, U.N. diplomats said.

But with loyalists holding out in the capital, in Gaddafi's coastal home city and deep in the inland desert, violence could go on for some time, testing the ability of the government-in-waiting to keep order when it moves from its eastern stronghold.

The tribes ... must march on Tripoli, Gaddafi said in an audio message broadcast on a sympathetic TV channel. Do not leave Tripoli to those rats, kill them, defeat them quickly.

The enemy is delusional, NATO is retreating, he shouted, sounding firmer and clearer than in a similar speech released on Wednesday. Though his enemies believe Gaddafi, 69, is still in the capital, they fear he could flee by long-prepared escape routes, using tunnels and bunkers, to rally an insurgency.

Diehards numbering perhaps in the hundreds were keeping at bay squads of irregular, anti-Gaddafi fighters who had swept into the capital on Sunday and who were now rushing from one site to another, firing assault rifles, machineguns and anti-aircraft cannon bolted to the backs of pick-up trucks.

In a southern district close to the notorious prison of Abu Salim, rebel forces launched a concerted assault, sweeping from house to house and taking prisoners.

HUNG FOR GADDAFI

Elsewhere, pro-Gaddafi forces shelled rebel positions at Tripoli's airport, and NATO warplanes bombed Sirte to the east -- Gaddafi's birthplace.

The rebels' Colonel Hisham Buhagiar said they were targeting several areas in their hunt for Gaddafi. We are sending special forces every day to hunt down Gaddafi. We have one unit that does intelligence and other units that hunt him down, he said.

While random gunfire broke out periodically across Tripoli, some of its 2 million residents ventured out to stock up on supplies for the first time in days.

Aid agencies sounded an alarm about food, water and medical supplies, especially for hundreds of wounded. But the new leadership said it had found huge stockpiles in Tripoli which would ease the shortages.

In a sign Libya's rebel authority was gradually taking over the levers of power from Gaddafi, National Transitional Council official Ali Tarhouni said the body had begun its planned move from Benghazi to Tripoli.

I proclaim the beginning of the resumption of the work of the executive office in Tripoli, Tarhouni, who is in charge of oil and financial matters for the council, told reporters at a briefing in the capital.

The shift is seen as a crucial step to smoothing over rifts in the country, fragmented by regional and tribal divisions, particularly between east and west.

Nonetheless, in order to begin installing an administration to offer jobs to young men now bearing arms and to heal ethnic, tribal and other divisions that have been exacerbated by civil war, Libya's new masters are anxious for hard cash quickly.

The deal between the United States and South Africa would allow the release of the funds without a Security Council vote on a draft resolution that Washington submitted on Wednesday after South Africa blocked a U.S. request to disburse the money in the U.N. Libya sanctions committee, U.N. diplomats said.

Some governments, notably in Africa where there was some sympathy for Gaddafi's view of his Western enemies as colonialist aggressors, had been reluctant to agree to it.

Speaking in Italy, the head of the rebel government, Mahmoud Jibril said the uprising, the bloodiest so far of the Arab Spring, could fall apart if funds were not forthcoming quickly: The biggest destabilising element would be the failure ... to deliver the necessary services and pay the salaries of the people who have not been paid for months.

Our priorities cannot be carried out by the government without having the necessary money immediately, he said.

FEAR OF FAILURE

After a meeting of officials in Istanbul, the Contact Group of allies against Gaddafi called on Libyans to avoid revenge.

The participants attached utmost importance to the realisation of national reconciliation in Libya, it said. They agreed that such a process should be based on principles of inclusiveness, avoidance of retribution and vengeance.

Gaddafi's opponents fear that he may rally an insurgency, as did Saddam Hussein in Iraq, should he remain at large and, perhaps, in control of funds salted away for such a purpose.

Western powers, mindful of the bloodshed in Iraq, have made clear they do not want to engage their troops in Libya. But a U.S. State Department spokeswoman said Washington would look favourably on any Libyan request for U.N. police assistance -- something some say might aid a transition to democracy.

Rebel leaders, offering a million-dollar reward, say the war will be over only when Gaddafi is found, dead or alive.

The ex-international high representative in Bosnia, Paddy Ashdown, told Reuters there was a need for speed if Libya's new rulers were to avoid a lingering threat from their predecessor, unlike what transpired in the former Yugoslavia and Iraq.

The best time to capture these defeated leaders is immediately after the conflict finishes, Ashdown said. The longer it takes the more chance they have of being spirited away to a place which is much more difficult to find.

The United States and NATO are also deeply concerned about possible looting and resale of weapons from Libyan arsenals as Gaddafi's rule crumbles, though the U.S. State Department said it believed Libya's stocks of concentrated uranium and mustard agent were secure.

TRIPOLI FIGHTING

With fighting raging in Tripoli, there was evidence of the kind of bitter bloodletting in recent days that the rebel leaders are anxious to stop in the interests of uniting Libyans,

including former Gaddafi supporters, in a democracy.

A Reuters correspondent counted 30 bodies, apparently of troops and gunmen who had fought for Gaddafi, at a site in central Tripoli. At least two had their hands bound. One was strapped to a hospital trolley with a drip still in his arm.

All the bodies had been riddled with bullets.

Elsewhere, a British medical worker said she had counted 17 bodies who she believed were of prisoners executed by Gaddafi's forces. One wounded man said he had survived the incident, when, he said, prison guards had sprayed inmates with gunfire on Tuesday as the rebel forces entered Gaddafi's compound.

French magazine Paris Match quoted an intelligence source saying Libyan commandos found evidence that Gaddafi had stayed at a safe house which they raided on Wednesday.

NATO was helping the rebels with intelligence and reconnaissance, Britain said, and its jets kept up their bombing campaign overnight.

There are areas of resistance by the regime which has had considerable levels of military expertise, still has stockpiles of weapons and still has the ability for command and control, said British Defence Minister Liam Fox.

They may take some time to completely eliminate and it is likely there will be some frustrating days ahead before the Libyan people are completely free of the Gaddafi legacy.

Nonetheless, many in Tripoli count themselves happy already that Gaddafi has gone. I was nine years old when Gaddafi came to power and I've always hoped I wouldn't die before I saw this day, said Ali Salem al-Gharyani, choking back tears.

I am now 50 years old and this is the first time, seeing Gaddafi gone, that I have experienced true joy in my life.

(Reporting by Peter Graff, Ulf Laessing, Mohammed Abbas and Samia Nakhoul in Tripoli, Robert Birsel in Benghazi, Hamid Ould Ahmed and Marie-Louise Gumuchian in Algiers, Souhail Karam in Rabat, Sami Aboudi, Omar Fahmy, Marwa Awad, Dina Zayed and Tom Pfeiffer in Cairo, Giles Elgood, Christian Lowe and Richard Valdmanis in Tunis, Silvia Aloisi in Milan, Tulay Karadeniz in Istanbul, Jon Hemming in London, and Louis Charbonneau at the United Nations in New York