In this Jan. 17, 2020, file, photo, Libyan Gen. Khalifa Hifter joins a meeting with the Greek Foreign Minister Nikos Dendias in Athens. Credit: Thanassis Stavrakis | AP

“Field Marshal” Khalifa Haftar’s retreat from Tripoli should not be confused with Napoleon’s retreat from Moscow. Haftar was foolish to try to capture the Libyan capital — it even surprised his foreign backers — but he probably won’t have to retreat very far. His main force is still intact, and it doesn’t snow much in Libya.

It’s probably too generous to call what has been going on in Libya a civil war. After long-ruling dictator Muammar Gaddafi was overthrown in 2011, the country actually disintegrated into a series of city-states ruled by rival Islamist militias — and every petty warlord got foreign backers because of Libya’s oil wealth.

Fifty years ago, Khalifa Haftar was one of the young officers who helped Gaddafi overthrow the monarchy. Twenty-five years ago, he was a CIA asset living in Virginia and promising to overthrow Gaddafi. Five years ago, he became the commander of the Libyan National Army and started subjugating the “Islamist and terrorist” militias that then dominated the east of the country (Cyrenaica).

As he gained control of Cyrenaica and then the desert south of the country, Haftar’s foreign backers multiplied — France, Russia, Egypt, the United Arab Emirates — for that’s where most of the oilfields, pipelines and oil terminals are. They also liked his strong anti-Islamist line. But they weren’t really interested in reuniting Libya, whereas Haftar was.

The various Islamist militias that dominate the capital, Tripoli, and the broader western region of Tripolitania are really just local boys defending their protection rackets. They have no loyalty to the unelected Government of National Accord (GNA) that the United Nations calls legitimate. The GNA, however, has gained the support of Turkey, probably the strongest country in the Middle East.

Why? Partly because under President Recep Tayyip Erdogan Turkey has become the key supporter of pro-Islamist regimes and parties throughout the Arab world (the GNA is dominated by the Muslim Brotherhood), and partly because of oil.

Still with me? Don’t bother to take notes; there won’t be a test.

Turkey didn’t instantly give military aid to the GNA when Haftar sent his forces west 14 months ago to attack Tripoli. That had to wait until Erdogan had extorted a deal last December in which Libya promised to sell Turkey lots of oil and gas (although it couldn’t deliver until Haftar was defeated).

The leader of the GNA, Prime Minister Fayez Sarraj, also had to agree to a deal in which Turkey and Libya carved up seabed rights in the Mediterranean in a way that gave Turkey valuable gas fields and froze both Greece and Cyprus out. (Both strongly objected, of course.) And then Turkey started sending arms, Arab mercenaries (also Islamist), armed drones and Turkish military “advisers” to Libya.

By early this year, Haftar was also getting a lot of foreign help: arms shipments from the UAE and Egypt, thousands of mercenaries from Sudan, Chad and Niger, and even a couple of thousand Russian ex-special forces troops now working for the Wagner Group of mercenaries. But Turkey’s bid was higher.

Haftar’s last assault on Tripoli failed late last month, and the GNA-Turkish counter-offensive has already retaken all of western Libya. As I write militias from Tripoli and Arab mercenaries provided by Turkey are fighting in the outskirts of Sirte, Libya’s third city and the gateway to the “Oil Crescent,” where the sea terminals of the pipelines are. If they take those, Haftar will be toast.

Except that the “alliance of evil,” as Erdogan calls Greece, Cyprus, Egypt, France and the UAE, won’t let that happen. More importantly, Russia won’t let it happen — and Russia flew more than a dozen state-of-the-art combat planes into a Haftar-controlled airbase last month.

And what’s extraordinary is that despite key words like “oil,” “Middle East” and “Russia” scattered all through this article, it hasn’t been necessary to mention the United States even once. There was a telephone call between Erdogan and President Donald Trump last week, but it’s unlikely to be relevant to the outcome.

The likeliest outcome is that Turkey backs off, there is a cease-fire of some sort that freezes the lines and there is a de facto division of Libya with a Haftar-led Russian client state in the east that shares the oil revenues with Tripoli. And then there will be a generation of quarrels over the shares.

Gwynne Dyer’s new book is “Growing Pains: The Future of Democracy (and Work).”