LONDON (Reuters) - Now Tripoli has risen, the main uncertainty is not whether Muammar Gaddafi's rule will survive, but whether the rebels can prevent Libya descending into chaos after he has gone.
There is no doubt Gaddafi's end is closer. With small groups of rebels fighting inside the capital and bigger rebel units battling their way towards the city, the veteran ruler is under unprecedented pressure days just days ahead of the Sept. 1 anniversary of the 1969 coup that brought him to power.
Assuming Gaddafi does fall, the rebels will quickly have to fill a power vacuum. The main rebel group, based in Benghazi in the country's east, consists of former government ministers who have defected, and longstanding opposition figures, representing a range of political views including Arab nationalists, Islamists, secularists, socialists and businessmen.
Far from monolithic, their military forces are a patchwork of armed groups, former soldiers and freelance militias, including self-appointed neighbourhood gangs and former members of an Islamist guerrilla group crushed by Gaddafi in the 1990s.
The challenges they face will be huge. The economy is in turmoil, communications are disrupted, public services are damaged and heavily-armed groups are likely to remain at large.
So far, though, the main rebel leadership has a poor track record of governing. Riven by factionalism, the NTC has struggled to bring security to the areas it controls. Analysts who study the opposition say some rebel groups in other parts of the country want nothing to do with the NTC, so unimpressive is its military record.
Will those divisions open up as the rebels take control?
"They are very concerned to avoid another Iraq and to get a smooth and clean political transition, but it could be very messy indeed," said Oliver Miles, a former British ambassador to Libya.
One thing that would help is a quick victory in Tripoli. That would likely improve the political climate inside rebel ranks, boosting the chance of a smooth post-Gaddafi transition, analysts said.
Saad Djebbar, a UK-based Algerian lawyer who once advised the Libyan government, said it would also help to bring in elders from all over Libya and from exile, people "who occupy respected positions in society and the professions to act like fathers of the nation."
"Their task will be to avoid a vacuum and provide a rallying point for all Libyans. The need is to avoid a vacuum (like Iraq after Saddam), so that the gains achieved can be shared by all.
"People on the rebel side have been acting extremely responsibly. The dangers of a transition have been exaggerated."
The NTC has spent months working on a post-Gaddafi plan that includes the establishment of a constitutional authority and UN-supervised elections.
In the United Arab Emirates, Libyan ambassador Aref Ali Nayad, who is in the opposition camp, told reporters a 70-person Libya Stabilisation Team had started operations in Dubai.
He said its goal was to supervise the post-war transition, including security, health, education and infrastructure.
"We expect internal and external security forces to stay in their offices after Gaddafi, they will only change their allegiance," he said.
The team has secured fuel supplies to be delivered after liberation. Post-Gaddafi authorities would abide by the law and not hold revolutionary courts, according to Nayad. "There will be no vengeance."
Western diplomats said the plans sound promising -- though much is still uncertain.
"The NTC are working hard on planning for D-Day which could be today although I'm not convinced it will be," said former British ambassador Miles.
"They claim to have a committee in place to manage power, water and police in the aftermath. They are determined to get the message out that they are not trying to cut anyone out and that it won't be a case of Benghazi taking over Tripoli.
"They say that if you exclude those who worked for Gaddafi then you'll exclude the whole population.
"But it's mostly words and it's not easy to be sure at this stage that there are actions to back it up."
One sign of division in rebel ranks came on July 28 when rebel military commander Abdel Fattah Younes was assassinated after he was detained by his own side for questioning.
Opposition leaders have linked Younes' killing to elements loyal to Gaddafi but there has also been widespread speculation that rivals in the opposition camp were responsible.
There were doubts about his loyalty and questions as to whether he, either by incompetence or design, was responsible for the sorry rebel performance in the east, diplomats say.
Ashour Shamis, a UK-based opposition activist and journalist, said the rifts were caused by the lack of military progress in the east. The advance on Tripoli meant those troubles are now fading, he argued.
"With Tripoli rising, the dynamic on the rebel side will change. The NTC is renewing itself. There's a lot of to-ing and fro-ing between Benghazi and Tripoli. There are good contacts."
And whether it is ready or not, the NTC is likely to be the main game in town.
Small, exiled opposition groups such as the Democratic Party may enjoy support in western capitals but is unlikely to play a major role. The party has argued that Libya should be run by the United Nations for a while. But diplomats say there are two weaknesses with that idea: Libyans don't want to be run by foreigners, and foreigners don't want to run Libya.
Gaddafi still has some cards. His military's lines of communication may be disrupted nationally but will be at their most resilient in the capital, and he is believed to have many spies in the city. Assuming he is still in Tripoli, he also has places he can move to, including his coastal hometown of Sirte, or Sebha in the interior.
But for outside observers, one of the most telling indications of the regime's collapse has been a late flood of defections by loyalists such as Gaddafi's former deputy Abdel Salam Jalloud.
Analysts say Jalloud had tried to escape at least three times previously during the rebellion. But Gaddafi's ability to keep loyalists in Libya against their will seems to be all but gone.
Some analysts, citing contacts in Libya and in exile, report defections to the rebels by Libyan intelligence service officers. Analysts argue that this, if true, would augur well for at least a period of political harmony post-Gaddafi.
"The years of brutality, and the need to prevent a return of Gaddafi to power, will unite the people," said Djebbar.
The question is, can they stay united once he's gone?
Reporting and writing by William Maclean; additional reporting by Mahmoud Habboush; editing by Simon Robinson