For months, Libyan rebels and their international supporters insisted that Libya was not going to become another endless conflict in the model of Iraq or Afghanistan. And when Tripoli was taken by rebels a month ago, it seemed to many that the war was over.

But as Moammar Gaddafi’s loyalists put up a fierce resistance in the besieged towns of Sirte and Bani Walid, and bickering erupts among the revolutionaries, there are growing fears that the ousting of Gaddafi will not mean an end to fighting in the new Libya.

In fact, some say the former leader’s defeat could open the door to a more complicated kind of conflict. For the first six months of the rebellion, there were two clear sides — Gaddafi forces and the rebels, with NATO tipping the scale in favor of the latter. But as that phase of the fighting draws to an end, disgruntled Gaddafi loyalists or others who feel left out of the new government could try to destabilize it, with insurgents striking in cities or using desert or foreign outposts as bases.

“Gaddafi for now is providing some sort of unified focus for resistance,” said Hugh Roberts, who until July was the North Africa director of the International Crisis Group, a conflict research organization. Without this focus, he said, Libyans who don’t feel represented in the new government might rebel. “It could be more diffuse, but presumably more difficult to cope with,” Roberts said, “and that’s where the situation starts to show some parallels to Iraq and Afghanistan.”

There are significant differences between this conflict and the two wars in which the United States and other Western nations have been embroiled for the past decade. Libya’s terrain — a vast open desert — is less conducive to a guerilla insurgency than Afghanistan’s mountains, though it bears similarities to Iraq’s landscape. And Libya’s 6 million people, who subscribe to one sect of Islam, are more homogenous than the ethnically and religiously diverse Iraqis and Afghans.

Perhaps most significantly, the impetus for the conflict was different here than in those countries. Here, the war was sparked by Libyans, who converged from across the country and abroad to create a ragtag army of anti-Gaddafi ground forces and a new government-in-waiting.

Although it is not clear how many Gaddafi fighters and weapons are holed up inside the remaining loyalist towns, including the southern town of Sabha, which rebels say they have partially captured, Libyan fighters and their international supporters say they expect them to eventually run out of food and ammunition, perhaps within weeks.

“They’re weak, they’re unstructured, they’re suffering to get supplies through, they’re being targeted very effectively, and they will run out of arms soon,” a Western diplomat here said on the condition of anonymity in order to speak more candidly. “The freedom fighters have excellent communications chains, and they have the regular support of NATO and other international support. There’s no question that the Gaddafi forces will be defeated, and it’s just a matter of time.”

In neighboring Tunisia, meanwhile, a court sentenced Libya’s former prime minister, Baghdadi al-Mahmoudi, to six months in jail after he was found guilty of entering the country illegally Wednesday night, Reuters reported Thursday.

An uncertain picture

But even after the holdout towns fall to the revolutionaries, Libya could become vulnerable to attacks from Gaddafi loyalists or other groups that feel marginalized in the new system.

Gene Cretz, the U.S. ambassador who returned to Libya on Wednesday after nine months, said he does not foresee an insurgency “on the scale that happened in Iraq” but worries that weapons could fall into the hands of al-Qaeda, which has a presence in the region. He also expressed concern about the possibility of fracturing among the rebels as they scramble for power in the new system, though he said he had confidence that they would be able to smooth out their differences.

“Nobody knows now what the political fabric of this country is going to look like after 42 years in which there was no political fabric,” Cretz said. “So I think there is a genuine cause to be concerned that things could go wrong.”

Ferhat Ahmed, former central bank governor of Libya and now a consultant based in Dubai, predicted it would take five years for Libya to stabilize. “If people don’t have a peaceful means for sharing of power, they will turn to guns,” he said. “If there is not intervention from international society, strife and violence will continue as long as there are weapons in the streets.”

NATO announced on Wednesday that it would extend its mandate in Libya, which had been set to expire Tuesday, by up to 90 days. A NATO spokeswoman declined to speculate about whether the organization would prolong its involvement in the case of a protracted insurgency.

Gaddafi warned of a prolonged insurgency, and the revolutionaries say they have taken pains to avert one. The temporary rebel government left seats open for people in Gaddafi-controlled areas to fill once they were able, hoping to avoid infighting. Western powers included Muslim and African countries in their decision to provide air support to the rebels, and avoided putting foreign boots on the ground, in a pointed message that this conflict was different from Iraq and Afghanistan. The new government also says the battle for the holdout towns is taking so long because its forces are trying to avoid the kind of indiscriminate shelling that could harm civilians.

Hard to read a nation’s mood

Gauging the likelihood of insurgency is difficult when there has been no objective assessment of Libyan popular opinion. While many in the capital have excitedly embraced the revolution, painting the city in its red, black and green colors, people opposed to the rebels say they are keeping quiet for now. And while the eastern part of the country has heartily supported the rebellion, the new government could be on shakier ground in southern Libya, where some tribal people are loyal to Gaddafi.

Rebel commander Abdulhakim Belhadj acknowledged the possibility of post-Gaddafi terrorist acts but said he thought they were unlikely to be widespread. “Some people from the Gaddafi regime, they might think to have revenge, but we should expect that,” he said.

Shashank Joshi, an associate fellow at the London-based Royal United Services Institute, agreed that Libya is unlikely to fall into a protracted insurgency. But he said the Transitional National Government should not delay in forming a new administration and starting the process that will lead to a new constitution, parliament and presidential elections.

“One of the mistakes that they’ve made is to say they’re going to wait to declare a government until all these towns are liberated — at that rate it could be Christmas before there’s a new government,” he said. “I think essentially they need to turn Gaddafi into an irrelevance.”

Staff writer Steven Mufson in Washington contributed to this report.