On October 6, during a phone call with Turkish President Recep Tayyip Erdogan, United States President Donald Trump agreed to move American troops out of northeast Syria to clear the way for a Turkish military operation to overthrow the Kurdish People’s Protection Units (YPG) from the area.

Trump’s decision led to a wave of criticism at home and abroad, with many accusing the president of abandoning America’s Kurdish allies. The move undoubtedly left the YPG, which played the leading role in the fight against the Islamic State of Iraq and the Levant (ISIL or ISIS) group in Syria, in a vulnerable position. However, much of the chaos and suffering we are witnessing today cannot be blamed on Trump’s impulsiveness alone. The ongoing Turkish offensive is, essentially, a by-product of the Obama administration’s incoherent and unsustainable policy concerning the conflict in Syria.

The YPG is the Syrian affiliate of the Turkish Kurdistan Workers’ Party (PKK), a Kurdish movement that has been waging an armed campaign against the Turkish state since the 1980s. Consequently, Turkey views the presence of any YPG controlled entity at its southern border as a major threat to its national security and territorial integrity. So, for Ankara, its ongoing incursion into northern Syria is an inevitable act of self-defence.

However, all this could have been avoided if the US had possessed a coherent strategy to prepare the region politically for its eventual withdrawal.

In 2012, in the wake of the Syrian uprising, YPG’s political wing, the Kurdish Democratic Union Party (PYD) and the Kurdish National Council (KNC), backed by the President of Iraqi Kurdistan Masoud Barzani, signed a cooperation agreement and formed the Kurdish Supreme Committee (KSC) to fill the power vacuum left behind by the retreating Syrian Army and to jointly administer Kurdish inhabited regions of northern Syria.

However, over time, the PYD became emboldened by the growing power and clout of its military wing and started to administer the region unilaterally. This, and the lack of a third party to oversee and enforce the conditions of the cooperation agreement, led the KNC to withdraw from the committee in 2013.

The PYD then established the Movement for a Democratic Society (TEV-DEM) coalition and, in January 2014, three areas under TEV-DEM rule declared autonomy. A few months later, ISIL laid siege to the TEV-DEM ruled autonomous canton of Kobane. The canton’s televised resistance and eventual victory against ISIL established the YPG fighters as the undisputed heroes of the conflict in the eyes of the international community.

However, the YPG did not win that struggle alone. Iraqi Kurds also supported the canton’s fight against ISIL, and Ankara allowed around 150 Iraqi Peshmerga fighters to cross from Turkey into Kobane. The US, meanwhile, supported the fight against ISIL with air raids.

Once Kobane was cleared of ISIL forces, given the support Iraqi Kurdistan and the Syrian Kurdish Pesmergha, allied with Barzani, offered to the canton, there was ample opportunity for the US to force the PYD to revive its agreement with the KNC.

Barzani has been an ally of Turkey for most of his time in power, and the KNC’s military wing, known as Roj Peshmerga, was trained by Turkey as part of Iraqi Kurdish Zeravani forces back in 2014.

A revival of the agreement between the PYD and the KNC back then would have made it extremely difficult for Turkey to justify an incursion into the region under the pretext of fighting terrorism now.

The US had enough leverage to enforce such an agreement given that both Iraqi and Syrian Kurds are US allies. Instead of paving the way for more cooperation between the PYD and the KNC, however, US policymakers such as Brett McGurk, the former special presidential envoy for the Global Coalition to Counter ISIL, chose to work only with the YPG.

Such a power-sharing agreement would not only have discouraged Turkey from moving into Syria, but it would have also positively affected Turkey’s ongoing conflict with the PKK. Given the YPG’s affiliation with the PKK, the developments in northern Syria have a direct impact on Turkey’s internal politics.

Back in 2013, the Turkish government was in negotiations with the PKK to settle their decades-long conflict. At the time, the leaders of the PYD met with Turkish officials in Ankara twice. However, following the collapse of the negotiations in 2015, relations between the two deteriorated. Although the main reason behind the end of the talks was the politicisation of the negotiations by Erdogan for electoral gains, another reason was the PKK’s growing power in Syria.

The gains made by the YPG in Syria made any deal between Turkey and the PKK meaningless, as a Kurdish statelet openly controlled by groups closely aligned with the PKK was quietly being built along Turkey’s southern frontier.

It is important to note that the PKK’s expansion in Syria gave the PKK leaders based in the Qandil Mountains in Iraqi Kurdistan an upper hand over the jailed PKK leader Abdullah Ocalan, with whom Turkey was negotiating during the siege of Kobane. Having said that, if the PKK’s role within the administration of northern Syria was contained by sharing power with the KNC, it could have convinced both Erdogan and the Qandil faction of the PKK to go ahead with a settlement.

Lastly, as the international anti-ISIL coalition’s boots on the ground, the YPG had overstretched its zone of influence into the majority Sunni-Arab areas of Syria, such as Deir Az Zor. Populations in these areas would never accept to live under Kurdish rule once the US troops leave Syria. This impending problem, however, could have been turned into an opportunity. The Kurds could have used their de-facto authority over majority Arab areas as a negotiating card with the Assad regime and their Russian backers to guarantee autonomy for the Kurdish areas after the US exit from Syria.

In short, simply by pressuring the PYD into a power-sharing agreement with the KNC, and encouraging it to use its influence in Arab-majority regions of Syria as leverage for autonomy, the US could have guaranteed the stability of northern Syria for years to come, and please Turkey, Iraqi Kurds and Syrian Kurds simultaneously.

Only a few years ago Obama left Iraq prematurely, without making political preparations to guarantee the country’s stability. This colossal mistake led to the rise of ISIL. Trump is now repeating his predecessor’s mistake in Syria. But his mistake risks not only paving the way for forces like Bashar al-Assad, Iran and Russia to fill the vacuum the US’s departure will undoubtedly leave, but also destroying Washington’s reputation as a reliable ally for years to come.

Trump is right. US troops cannot stay in the Middle East forever. But a premature departure is likely to be more destructive than any other scenario.

The views expressed in this article are the author’s own and do not necessarily reflect Al Jazeera’s editorial stance.