CAIRO — Martin Kobler, the United Nations envoy to Libya, used to regularly joke that the only functioning government in Libya was the Islamic State. Unlike the country’s other three governments, it not only held territory but ran the courts, provided services to the public and ensured security — however harsh its rule.
Fortunately, Mr. Kobler said recently, his joke is now out of date, with the Islamic State reduced to three neighborhoods in the coastal city of Surt, and its headquarters in the hands of militias supporting the new United Nations-backed government. “This is over now,” he said.
The problems of governing Libya, however, are far from over, particularly as its many remaining factions try to figure out what comes next at a potential second round of talks this month, presided over by the United Nations. Surt’s future will loom large in the discussions.
Ever since Libya’s longtime ruler, Col. Muammar el-Qaddafi, was deposed and killed in Surt in 2011, the country has been divided by tribal and militia rivalries. With a population slightly larger than that of Miami, Libya has no clear central government and scant possibility of exploiting its enormous oil reserves, the ninth largest in the world.
That a United Nations-backed government in Tripoli was able to dispatch a militia force to subdue the Islamic State in Surt was the first piece of good governance news in five years of vicious internecine fighting.
But even victory in Surt remains worrisome. First of all, the militias have to finish clearing out remnants of the Islamic State from the three city neighborhoods. The militias are reported to be close to accomplishing that, which will then raise the question of what they will do next.
They are from Misurata, a coastal city seen as a rival of Surt. While they were nominally doing the bidding of the new, United Nations-backed Government of National Accord, or G.N.A., it is not at all clear that they will continue to accept its authority.
Then there are Libya’s other factions. The government in the eastern city of Bayda, with its Parliament in Tobruk, once enjoyed international support but now relies mostly on Egypt and some Persian Gulf allies. It is also suspicious of the intentions of the Misuratans, and angry about United Nations backing of the G.N.A.
The country’s most powerful military leader, Gen. Khalifa Hifter, based in Benghazi, has almost entirely cleared that city, the east’s biggest, of the Islamic extremists who once held sway there. But he, too, is deeply suspicious of the Misurata militias, because they are dominated by Islamists. While General Hifter has been named the Libyan National Army commander, politically he operates independently.
That is true as well of the third faction claiming to rule Libya, a Tripoli-based Islamist militia grouping that has a Parliament separate from that of the G.N.A.
“The government has to implement state authority over who dominates this area,” Mr. Kobler said. That the Misurata militias were acting on behalf of the G.N.A. when they ousted the Islamic State from Surt was a very positive sign, he said.
“It shows the strength of the G.N.A.,” he added. “The other two governments do not exist. A government should provide security, basic services. That is not the case from those two governments.”
It is important as well, he said, that an international consensus is building to support the G.N.A., with the Arab League and the African Union calling on their members not to back other factions’ claims to legitimacy; the success in Surt bolstered that consensus.
The same consensus does not seem to exist in many parts of Libya. The government based in Bayda has denounced the G.N.A. In Benghazi, General Hifter has boycotted the meetings that the United Nations has convened to bring all of the factions together, and he is by far the strongest military player.
When Surt finally falls, said Ahmed el-Mesmari, the spokesman for the Libyan military in the east, the militias there will abandon the new Tripoli government.
“We don’t think anyone can control these forces,” Mr. Mesmari said. “They are anarchists and extremists. They are closer to Qaeda than they are to anyone else. They would be very hard to tame.”
Even internationally, the picture can be confusing. Special Forces troops from the United States and Britain were advising the militias in Misurata in the fight against the Islamic State, and American air power was decisive in their advances against the extremists. Italy sent its own secret service operatives to Tripoli to work with the G.N.A., according to Italian news reports.
Tripoli itself is fragmented by numerous militias with shifting alliances, not all of them supporting the United Nations-backed government.
“By our count, there are 40 militias and gangs in Tripoli,” Mr. Mesmari said. “The city is a barrel bomb waiting to drop.”
His criticism is common among Libyan politicians in the east.
“It is a stillborn government bound to fail,” said Abu Bakr Buera, a member of the Tobruk Parliament. The problem would be easy to solve, he added. “We just need to put everyone in one room, and it would take just a few hours,” he said. “The problem is getting everyone in one room.”
In fact, the easterners have been conspicuous in their absence, with many members refusing to join last year’s Libyan Political Agreement talks, which led to the new G.N.A. in Tripoli this year.
Ali Busitta, a municipal official from Misurata, said he expected that once Surt was cleared of the Islamic State, the militias would continue to support the new government.
“Local officials and leaders secured this agreement with the militias with the U.N.’s blessing,” he said. “That’s why the U.N.-backed government was able to enter Tripoli without a fight.
“And we need to stop thinking of these people as militias,” he continued. “They stopped being that a while ago. They are far more organized now. They take orders. They have a structure. They have military IDs. They are an army. There is no reason to worry about Tripoli.”
Mr. Kobler said the confused state of Libya’s military and political factions was not surprising, but was a legacy of its history.
“This country never had strong institutions, even during the time of Qaddafi,” he said. “It’s tough to do this because it’s being done for the first time, and it’s a long and protracted process. ”
If what is happening in Libya is hard to follow, Mr. Kobler said, there is a simple explanation underlying everything: “It’s all about power and oil and money. That’s all you have to know.”