Turkish President Recep Tayyip Erdogan has been warning for weeks that he planned to hit the Syrian Democratic Forces deep inside Syrian territory, and after sending a significant force to the border, he has now managed to cut a deal with Donald Trump. The US president is keeping his promise to voters by pulling back US forces, as Turkey prepares to take over the scene in northern Syria at the expense of thousands of captured ISIS militants.

Through this agreement with the US, Turkey has strengthened its position in the Western alliance as the guardian of refugees and others, such as jihadist rebel groups and now ISIS members, that the superpowers don’t want to deal with.

After the earlier European Union deal with Turkey to keep Syrian refugees out, Erdogan has made a bargain of great importance once again, and proved himself to be, however unlovable, an indispensable partner of the West because of his country’s position as a needed barrier between Europe and the Middle East. Western tolerance toward the North Atlantic Treaty Organization’s regional allies, Saudi Crown Prince Mohammad bin Salman and Egyptian President Abdel Fattah el-Sisi for example, gave Erdogan an opportunity to undermine the Western standards of democracy and consolidate his power, but he nevertheless remained an ally necessary for both the EU and the US.

Though they certainly dislike the Turkish president’s constant dissatisfaction with the EU, the necessity of Turkey as a host to refugees has always outweighed Turkish insolence in the eyes of EU leaders. The country has been leaving Western values behind and turning its foreign policy into a one-man show. But if the West can live with Mohammad bin Salman, especially after his rogue operation in Istanbul was exposed by the Turkish government, it could come to terms with Erdogan too.

Turkish officials and media figures have been portraying the US announcement on the Syria pullout as a victory, but in reality, what Turkey has achieved isn’t a victory, but a mere approval to fight. Trump threatened that he would “totally destroy and obliterate the economy of Turkey” if Ankara exceeds the limits. What those limits are is unknown for now, but it’s clear that the US president wants to portray himself as in full control while leaving the Kurds, America’s partners in the field, face to face with the incoming Turkish Army.

Also read: Trump could pay political price for betraying Kurds

Especially after the US has cleared the border area of YPG (Kurdish-led People’s Protection Units) fortifications and heavy guns during the past month’s joint patrol efforts in the eastern Euphrates region, Syrian Kurds feel betrayed. Prominent SDF figures are calling for an all-out war, but it’s uncertain whether there will be heavy clashes deep inside Syrian territory, or if Turkish forces will advance just so far and then stop. The limits mentioned in Donald Trump’s tweet will most likely determine the course of events.

The US had already partially left the scene when former president Barack Obama’s Syria policies proved hollow, and Trump had already expressed his wish to pull US troops from Syria last year. After the firing of John Bolton, the hawkish former national security adviser to the US president, and stressful impeachment hearings en route, this was the best time for Erdogan to cut a deal with Trump.

Just like what happened in the Pastor Anthony Brunson case, Trump and Erdogan have taken a personal approach to this matter. Trump’s Republican allies blasted the withdrawal decision right after the White House statement. On the other hand, according to the main Turkish opposition Republican People’s Party (CHP), regarding Turkey being responsible of captured ISIS members, “Russia gave Turkey the watchman’s duty in Idlib, and now the US is doing the same.”

The Turkish president has gradually turned his eyes on the SDF after his party’s embarrassing local-election defeats at the end of March. Having lost in nearly all the major cities at the local elections, Erdogan’s AK Party is in despair. Dissidents have officially left the party and started two separate movements to tear off big chunks of voters. Currency crises hit the country last year and refugee influxes started causing discontent. Erdogan, the architect behind the presidential governing system, began losing his popularity to opposition figures.

Against the expectations of Turkish policymakers, the Syrian regime didn’t fall easily, and having super executive powers over every institution of the state made Erdogan seem the only individual responsible for his country’s decline. A wider and longer war deep inside Syrian territory, against local forces that are highly motivated about defending their home towns, also has the potential of turning the tables on Turkey’s internal politics. And if as suggested in his recent tweets, Trump wishes to stop Turkey at some point, the damage of American sanctions might become unbearable.

Erdogan seems to think that all his problems can be shelved when the ultimate fight against Syrian Kurds starts, but if the offensive takes longer than expected, the end-game might turn into a dead-end for Turkey’s ruling circle.