BEIRUT — Syria's long-running civil war may be winding down slowly, but the country is awash in weapons and a confounding array of local militias and thousands of foreign troops, some of which may never leave.
With crucial aid from allies Iran and Russia, President Bashar Assad has regained control over large areas of Syria in advances that appear to have put to rest the possibility of a military overthrow, at least for now. But his rule is extremely reliant on continued assistance from Iranian-sponsored militias, which have spread across the war-ravaged country.
The fight against the Islamic State group, which proliferated soon after the conflict began in 2011, has provided a convenient justification for foreign troops to be deployed in Syria with the pretext of fighting the extremists. Now that IS no longer holds any significant urban territory in Syria, the numbers of some forces may be scaled down, but foreign powers with longer-term ambitions and interests will try to maintain a presence in the country for years to come. That will further complicate prospects for a peace settlement.
Some countries have already indicated that they plan to stay for the foreseeable future.
The presence of U.S. troops in northern Syria was initially meant to help train and support Kurdish-dominated local forces fighting the Islamic State group.
The number of troops has grown gradually. Although the official limit on U.S. troops has remained at 503 since shortly before President Barack Obama left office, the actual number is now believed to be more than 1,500, including special forces, a Marine artillery unit, forward air controllers and others. They are spread across more than a dozen bases in northern Syria.
The end of the fight against IS takes away any legal justification for the presence of U.S. troops in Syria, but U.S. officials are now suggesting they plan to maintain a U.S. troop presence in the north until an overall settlement for the war is found. That has raised concern about a more permanent project that risks drawing the U.S. into a conflict with Syria and Assad's ally, Iran.
"We're not just going to walk away right now before the Geneva process has cracked," U.S. Secretary of Defense Jim Mattis said earlier this month, referring to the U.N.-backed political talks.
Kurdish officials have asked the U.S. to stay on, fearing that a quick withdrawal would facilitate Assad's forces swooping in on Kurdish-held territory in the north.
Earlier this month, the Syrian government called on the United States to withdraw its forces now that the fight against the Islamic State group is nearly over. The Foreign Ministry statement said the presence of U.S. troops will not force a political solution to the conflict.
Russia has never said how many of its military personnel, warplanes and other weapons are in Syria. Turnout figures in voting from abroad in the September 2016 parliamentary election indicated the number of Russian military personnel in Syria at the time was about 4,300. The Russian presence has likely increased, as Moscow this year deployed its military police to patrol so-called "de-escalation zones" in Syria.
Open-source materials — including video from the Hemeimeem air base, the main hub for the Russian military in Syria since its campaign began in September 2015 — indicate that Russia has several dozen jets and helicopter gunships there.
Russia also has deployed special forces to conduct intelligence and coordinate airstrikes. Senior Russian military officers also have helped train and direct Syrian government troops. In recent months, Russian military police have become increasingly visible in Syria.
The chief of the Russian military general staff, Gen. Valery Gerasimov, said last week that Russia will "significantly" reduce its military foothold in Syria as the campaign nears its end.
At the same time, he indicated Russia will maintain a presence at both the Hemeimeem air base and the navy supply facility in Tartus. Gerasimov added that the military's Reconciliation Center, a group of officers who have helped negotiate and maintain truces in Syria and coordinated the delivery of humanitarian aid, also will stay.
Syria has allowed Russia to use Hemeimeem air base indefinitely without cost. Moscow also has signed a deal with Syria to use the Tartus base for 49 years, which could be extended if both parties agree.
The Russian military plans to modernize the air base to allow it to host more warplanes. It also intends to expand the Tartus facility significantly to make it a full-scale naval base capable of hosting warships, including cruiser-sized vessels.
THE IRANIANS AND SPONSORED MILITIAS
Of all the foreign troops in Syria, perhaps none have been as widespread and potentially lasting as the Iranians. The Islamic Republic of Iran has made an enormous effort to keep Assad in power, providing extensive military and financial support throughout the six-year civil war.
It has deployed Islamic Revolutionary Guards in Syria as well as Iranian officers who provide military and political support. Iranian officials say more than 1,000 Iranian fighters have been killed in Syria and Iraq after they were deployed to defend Shiite holy shrines.
Tens of thousands of Iranian-sponsored pro-government local militias known as the National Defense Forces are deployed across Syria, in addition to Iraqi Shiite militias and thousands of Iranian-backed Hezbollah fighters from Lebanon who have been key factors in turning the war in the government's favor. Hezbollah is deployed in wide areas along Syria's border with Lebanon, where the Shiite group has built military facilities and long-term bases it is unlikely to leave anytime soon.
Iran's strategy aims to ensure it can continue to pursue its vital interests after the war, using parts of Syria as a base and making certain that a land corridor from Tehran to Beirut remains open.
Turkey first sent ground forces into Syria last year in a campaign dubbed "Operation Euphrates Shield." It was aimed at fighting the Islamic State group, although Turkey also seeks, above all, to limit the expansion of Syria's Kurds along its border with Syria. Ankara perceives the Syrian Kurdish fighters to be an extension of the Kurdish insurgents who have waged a three- decade insurgency in Turkey.
Turkish officials have not disclosed how many Turkish soldiers are deployed in Syria but security experts estimate that at least 2,500 troops are stationed in a swath of territory revolving around the towns of al-Rai, al-Bab and Jarablus — a border zone that Turkey and Turkey-backed rebels took back from IS last year under "Euphrates Shield."
An estimated 400 more Turkish troops are in the Idlib region as part of an agreement reached among Turkey, Russia and Iran to create a "de-escalation zone" in the area.
Turkey is building schools and hospitals in areas liberated under "Euphrates Shield" to encourage the return of refugees, and it was unclear how long the Turkish troops would stay in the zone.
President Recep Tayyip Erdogan has suggested that the Turkish troops could target a Syrian Kurdish group that Turkey considers to be a security threat in the Afrin region, north of Idlib, once the "de-escalation" mission is over.
Associated Press writers Suzan Fraser in Ankara, Turkey, Vladimir Isachenkov in Moscow and Jon Gambrell in Dubai, the United Arab Emirates, contributed.