Libya faces a number of nightmare scenarios, from a new civil war between rival factions to the rise of al Qaeda-affiliated Islamists, should a power vacuum plunge the country into a new phase of lawlessness and chaos.
Can Libya's next leaders avoid creating new divisions?
There is a new smell of fear circulating under the sweet scent of victory; a fear that the National Transitional Council (NTC) is incapable of uniting and controlling the diverse elements within the rebellion and that the tribal rivals which are beginning to bicker over the spoils of war may soon start fighting each other over them.
With the possibility of Libya becoming a nation governed by a NATO-backed, weak and undemocratic central administration led by a compliant president and besieged by Islamist militants, some commentators have likened the unfolding situation as one akin to Afghanistan.
Others have rejected this, saying that Libya lacks a meddling neighbor like Pakistan, secretly supporting or condoning Islamist militias within the unstable state. Libya's closest neighbors, Tunisia and Egypt, are themselves preoccupied with their own post-uprising recovery.
NTC leader Mustafa Abdul Jalil faces a severe challenge
Some have used the same argument to reject claims that Libya could become the next Iraq as it is not unsettled by external forces like Iran or Saudi Arabia. Unlike Iraq in the wake of Saddam Hussein's fall, Libya also has a government-in-waiting which has made preparations for a takeover - however flawed and undermined these may be.
Libya does, however, have similarities to both conflicts and is already showing elements of both which NATO will be acutely and painfully aware of.
Just as in Iraq, Libya faces the prospect of elements that supported the ousted Gadhafi regime attempting to fight their newfound marginalization and preserve their power bases. If the rebels crack down on former regime figures, then any backing for the Gadhafi regime which has been driven underground could re-ignite and galvanize support for any insurgency.
"The NTC will have to accomplish three urgent tasks to avoid this: disarm the population, ensure that all sectors of society are represented in its governance structures, and revive the economy as soon as possible," Alia Brahimi, a Middle East expert and author, told Deutsche Welle.
"It is also imperative that the NTC does its utmost to avoid civil strife and to try to provide everyone, including former regime elements, with a stake in a stable and free Libya."
Just like in Afghanistan, a Western-backed NTC government may have to face up to battling an Islamist insurgency fuelled by extremist groups, some of whom have close ties to al Qaeda.
Threat of al Qaeda
There have been rumors of an al Qaeda presence ever since the war began but the rebels have been quick to reject claims that they have any links from the outset.
NATO has seen hints of an al Qaeda presence among rebels
However, the leaders of the US, Britain and France have since admitted that they were aware of an Islamist element within the rebel forces before pledging their support, although they considered it to be "containable." US Admiral James Stavridis, a top NATO commander, revealed in March that he had seen "flickers" of an al Qaeda presence among the rebels.
"Of course al Qaeda would thrive, in the short-term, in any regional power vacuum, but not in the long-term, as it would have about as much to offer the Libyan people after decades of tyranny as it did to Iraqis - nothing," Brahimi said.
As the rebels have advanced through Tripoli, a better picture of which groups actually make up the alliance has materialized. While no hardcore al-Qaeda affiliates have been identified, a number of Islamist groups have set alarm bells ringing in NATO.
The February 17th Martyrs Brigade, which has a strong presence both in the east, the Western Mountains and Misrata, is one of the strongest militias in the alliance and is led by the cleric Ismail al-Sallabi and former members of the Libyan Islamic Fighting Group (LIFG). The Islamic militant group waged a campaign of violence against Gadhafi's regime in the 1990s and was banned internationally as a terrorist organization after the 9/11 attacks.
The Abu Ubaidah bin Jarrah Brigade is another causing concern. The radical Islamic militia has rejected NATO intervention and has refused to fight under the NTC command, branding the council and their NATO backers "infidels." This brigade was handed responsibility for the internal security for the liberated areas of the country as the rebel advance pushed toward Tripoli.
Rising Islamist popularity
Another LIFG link comes in the form of Abdelhakim Belhadj, the group's former leader who fought alongside the Taliban and al Qaeda in Afghanistan before fleeing to Iran and eventually being arrested by the CIA in Malaysia. He was then renditioned back to Libya and imprisoned along with some 1,800 LIFG fighters by Gadhafi in 2004 before being released in 2010 after renouncing violence.
Rebel from the Tripoli brigade under the command of Belhadj
After leading the Tripoli Brigade in the assault on Gadhafi's Bab al-Aziziyah compound in the capital, he is now the leader of the newly established Tripoli Military Council.
Belhadj is now widely believed to be one of the most popular leaders of the Libyan revolution and a figurehead for the growing number of Islamists among radicalized militiamen within the rebel alliance.
Dr. Kristian Ulrichsen, a North Africa and Middle East expert at the London School of Economics, believes that, while this Islamist link is worrying, the LIFG threat may be overstated, as it operated within a domestic Libyan context.
"The LIFG denied affiliation with al Qaeda and its leaders were extremely and openly critical of al Qaeda's tactics," he told Deutsche Welle. "There is support for the Islamization of Libya which carries with it undertones of al Qaeda, but to the extent that if links existed, these would have been at individual level, with Libyans travelling to Iraq to take part in the insurgency there, rather than through institutional cooperation."
According to Brahimi former LIFG militants like Belhadj and "young Islamists in towns such as Derna and Ajdabiya will bear the primary responsibility in ensuring that al Qaeda is not able to make in-roads in Libya during the transitional phase."
A more dangerous element could be the Salafists. About 600 Salafist extremists with experience of fighting in the Iraq insurgency were broken out of the Abu Salim prison by rebels swarming through the Libyan capital last week.
Awash with weapons
Light and heavy weaponry has been looted from bunkers
The immediate chaos and lawlessness which follows in the wake of a deposed regime has also given rise to another element which could lead to widespread instability and violence in Libya: the country is now awash with guns. Given their experience and the proliferation of weapons in Libya, the fear is that these Salafists may join with or create their own Islamist militia with their own agenda.
As seen in countries such as Somalia and Yemen, the continued chaos arising from a state of conflict can exacerbate the circulation of military hardware among a fractious tribal society. As a result, Libya's stability has surely been undermined by the looting of Gadhafi's stockpiles.
A recent report in the Los Angeles Times described how only a few of the 523 arms bunkers discovered to date in Libya are being protected by NTC guards. These, according to the report, contain everything from small arms to shoulder-launched Soviet Sam-7 anti-aircraft missiles. There were even alleged to be supplies of napalm in some. Meanwhile, the Guardian reported last week that Gadhafi's supplies of mustard gas, which were being monitored by NATO, have now disappeared.
Should NATO be forced to commit to a long-term engagement in Libya, it may find itself in a situation more reminiscent of Afghanistan than Iraq; after the US helped the Mujahedeen to drive out the Soviets, the rebels they armed later morphed into the enemy which began killing US and ISAF troops with the weapons they themselves provided. After arming the rebels against Gadhafi, there is a chance - should the situation deteriorate - that NATO may find itself dodging its own bullets.
NATO will find it very difficult to walk away from a new Libya war
"If post-Gadhafi Libya descends into chaos and forces NATO into taking sides in a civil war, the tensions on the alliance might become insurmountable," Ulrichsen said, adding that any protracted engagement in Libya could have serious consequences.
"There was no consensus among NATO members for engaging in Libya, and any deterioration might bring to a head simmering tensions relating to Afghanistan as well."
Author: Nick Amies
Editor: Rob Mudge