The forces of the military leader Khalifa Hifter on Thursday retreated from their last footholds in the suburbs of Tripoli, the Libyan capital, ending his 15-month-old campaign to capture the city.
Mr. Hifter, 76, a former Libyan Army general and one-time C.I.A. asset, has fought for years to try to rule Libya as a new strongman and he launched his assault on Tripoli last spring in a last-ditch, all-or-nothing attempt to fulfill his goal.
Insead, his assault transformed what had been a simmering civil conflict among rival Libyan factions into an increasingly open proxy war among rival international powers.
The Russian mercenaries and Emirati air power backing Mr. Hifter had appeared to make his forces almost unstoppable at the start of this year. Then, the intervention of the Turkish military — and its deployment of brigades of paid Syrian fighters — helped turn the tide and instead delivered Mr. Hifter a stinging defeat.
But with so many foreign powers now entrenched in the contest to dominate Libya, analysts said, the collapse of Mr. Hifter’s Tripoli offensive was more likely to mark a new turning point in the conflict rather than a de-escalation.
Mr. Hifter’s foreign backers, principally from Russia and the United Arab Emirates, have pulled back from the former front lines around Tripoli. But none have so far shown any sign of withdrawing their forces or weaponry from Libya, and the Pentagon last week accused Russia of sending 14 fighter jets to support the Russian mercenaries on the ground.
“The war is not over,” said Emadeddin Badi, a senior fellow at the Atlantic Council, whose research focuses on Libya and the Sahel “There is clearly more conflict still to come, but everybody — domestically and externally — is going to recalculate their position.”
Libya has been in a state of perpetual turmoil since the ouster of Col. Muammar al-Qaddafi during an Arab Spring revolt in 2011.
Tripoli, however, remained the seat of a weak United Nations-sponsored provisional government protected by local and regional militias based in the Western region around the city.
A surprise attack last spring brought Mr. Hifter’s forces to the outskirts of the city, but his offensive then stalled in the face of newly galvanized opposition from the militias around the city.
The battle lines remained almost unchanged until Mr. Hifter’s forces suffered a string of losses over the previous three weeks. Those losses culminated Wednesday night with a retreat from the wreckage of the former Tripoli International Airport and on Thursday with the pullout from the southern suburbs.
Residents said Thursday that Mr. Hifter’s forces had fallen back to the town of Tarhuna, southeast of Tripoli. The leaders of the tribe based there had conducted their own long-running feud with the coalition of militias that dominate Tripoli even before they struck up an alliance with Mr. Hifter at the start of his attack on the capital.
With the militias that had defended Tripoli now pursuing his retreating forces, some analysts said they feared it could become the site of a prolonged battle or bloody reprisals.
“You would hope there is disciplined leadership, but in the fielded forces the emotions run high and there are always concerns,” said Frederic Wehrey, a scholar at the Carnegie Endowment of International Peace who has been a frequent visitor to the front lines of the fighting.
As his Tripoli offensive was foundering, Mr. Hifter had already been facing challenges to his power from within his own territory in eastern Libya, centered around the city of Benghazi.
In April, a prominent eastern Libyan politician who had been a close ally, Aguila Saleh, publicly proposed the creation of a new ruling council as an alternative to Mr. Hifter, prompting him to reprise his previous announcement that he was seizing direct control as a new military ruler.
“There were already cracks in his alliance,” Mr. Wehrey said.
The provision of weapons and resources from his foreign backers — including millions of dollars in counterfeit Libyan currency printed in Russia — has always been essential to Mr. Hifter’s control of an unwieldy coalition of militias and tribes. Now, analysts say the failure of his Tripoli offensive will raise new questions about his credibility with those backers, including Russia and the U.A.E. as well as neighboring Egypt.
Turkey, on the other hand, now faces new questions about how it might seek to capitalize on its gains.
President Recep Tayyip Erdogan of Turkey earlier this year sought to broker some new accommodation in Libya through bilateral talks with his Russian counterpart, President Vladimir V. Putin. Now, an apparent agreement by Turkey to allow Russian-backed fighters to withdraw unmolested from a base in western Libya has stirred speculation about a new attempt at a deal.
Even within Tripoli, analysts said, Mr. Hifter’s pullback may prompt new struggles for power. After previous rounds of civil strife in Libya, victorious militias have often demanded key positions and other spoils from successive interim governments.
Now the militias that played the biggest part in turning back Mr. Hifter “are not just going to pack up and leave,” Mr. Badi said. “They will expect something in exchange.”