Two big powers arm-wrestle in Syria. Neither one is the United States.

It is just as well that, when he met with Russian President Vladimir Putin in the Kremlin March 5, Turkey’s President Rejep Tayyip Erdogan did not look up to his right. If he had, he would have seen towering over him a lofty statue of Russia’s Catherine the Great, who in the 18th century sheared Erdogan’s Ottoman forebears of much of their European territory and many of their rights in the shared Black Sea.

The deal that Erdogan and Putin concluded in Moscow was less devastating than what Catherine imposed on the Ottomans. But it nonetheless represented a considerable setback for the ambitions Erdogan had been pursuing in Syria’s northwestern Idlib province. For many years Turkey has provided arms and other support to the Al-Qaeda-affiliated jihadists of the Hay’at Tahrir al-Sham (HTS) network who control most of the enclave, as well as political support to their quest to overthrow the Syrian government.

Under the terms of the Moscow Agreement, Turkey agreed to pull back some of the troops it had sent into Idlib over the past month and to participate in joint Turkish-Russian patrols along two of the enclave’s strategic highways that HTS had controlled until early February. This pushes HTS and those civilians under its sway into a much smaller area than they previously enjoyed.

The Moscow Agreement was reached one week after the Russian Air Force, which commands all the airspace of northwestern Syria from its base at Khmeimim, used bunker-buster bombs to blast a Turkish expeditionary force heading south to reinforce crumbling HTS positions. The Russian strikes killed dozens of Turkish soldiers and wounded many more.

That February 27 incident was devastating for Erdogan, who has faced mounting criticism at home for the bombastic and expensive policy he has pursued in Syria since 2011. In the days that followed, he tried to win support for his Idlib campaign from fellow NATO members in Europe and the United States, but he failed. For NATO, acting inside Syria was clearly an “out-of-area” operation. (The U.S. response was fairly muddled. The administration’s “Special Representative for Syria”, Amb. James Jeffrey, briefly traveled through a Turkish-controlled border point for a photo op inside Idlib and promised that Washington would send “ammunition” to help the fighters there. That promise was immediately shot down by the Pentagon.)

Erdogan was also careful to assign blame for the fatal air-strikes not to Russia but (quite implausibly) to Syria’s own, much less capable, air force. And to assuage his supporters’ desire for vengeance he authorized a military pummeling of Syria’s front-line positions, inflicting large numbers of casualties on ground fighters of the Syrian and allied forces—but not the Russians.

Moscow has had a close military and political relationship with Damascus since the 1960s and has long had a military presence in the country at the invitation of its government. But for a fateful 48 hours after February 27, the Russian military did nothing to help defend the Syrian positions round the Idlib enclave. That pause indicated that serious discussions were underway in Moscow over the extent of Russia’s commitment to Syria. Some members of Russia’s political elite have warned that Syria might become an Afghanistan-like quagmire for the Russian military. Others, including those close to the military, have described it as a useful testing-ground for Russian military systems as well as a way to continue asserting Russian interests in, and relevance to, the broader Middle East.

After the 48-hour pause, Russian air operations resumed in Idlib, and over the days that followed the Syrian and allied ground forces regained control of areas they had briefly lost during the pause. Meantime, Ankara was conducting intense contacts with governments around the world—including Russia. Erdogan’s first choice was reportedly to invite Putin to come meet him in Ankara. But he soon bowed to reality and obeyed the call to travel to Moscow instead. There, he held nearly six house of talks with Putin before signing the Moscow Agreement under the Catherine the Great’s stern gaze.

For Americans watching the geopolitical kaleidoscope shift at a sometimes confusing speed in Syria, it is crucial to try to understand the motivations of the many forces intervening there, as well as to learn about the limits of such interventions by outsiders and the benefits (as well as the costs) of a principled realism in such situations.

In Moscow and Ankara, two strongly nationalistic leaders, both endowed with a wily realpolitik-style realism as well as a strong dose of paranoia, perform an intriguing and complex diplomatic dance around each other… and the benighted civilians of Idlib and the rest of Syria are tightly entangled in that drama.

For Erdogan, the past few years have forced him to set aside the goal he pursued aggressively in Syria from 2011 through late 2014: that of toppling President Bashar al-Assad and replacing him with a ruler more in line with his own militantly Islamist way of ruling. In 2014, the eruption of the world-threatening ISIS caliphate in the heart of the movement Erdogan had tried to build in Syria caused a recalibration– though he remained quite happy to work closely with the Al-Qaeda-affiliated groups that preceded HTS, and then with HTS itself. As of now, he has probably concluded that toppling Assad is impossible; but he clearly still aims to retain de-facto control over whatever portion of the Idlib enclave he and his allies can hold onto.

Erdogan has also viewed Syria through the lens of his audacious project of using Turkey’s crucial strategic location to play NATO (and Europe in general) off against Russia. Last year, Turkey took delivery of its first shipment of the Russian S-400 missile-defense systems that Erdogan had ordered in 2017. For a NATO member, this was a breathtaking purchase; and it caused Washington to dial back considerably on plans to deploy advanced F-35 fighter planes to Turkey.

Inside Syria, Turkey has clashed both with Russia (over Idlib and more broadly) and with the United States—primarily over Washington’s support for the Kurdish-led “Syrian Defense Forces” (SDF) in northeastern Syria, which Erdogan judges, correctly, to be linked to Turkey’s own Kurdish-separatist insurgents.

Erdogan has also, in 2015 and more recently, cynically used the issue of the millions of refugees generated by Syria’s lengthy civil war as a tool to put pressure on Europe. In 2015-16, he “succeeded” in winning promises of 6 billion Euros of annual aid from Brussels to help him deal with Syrian refugees inside Turkey, on condition he cease pumping them west into Bulgaria and Greece, as he had in 2015. This past February 29, Turkish government bodies started pumping refugees west once again, in an attempt to win European support for Erdogan’s military expedition in Idlib. But he failed to get that, succeeding only in winning promises that they would consider increasing their humanitarian aid to Turkey.

For Putin even more than for Erdogan, his policy toward Syria has involved balancing many competing goals. After Erdogan decided in summer 2011 to reverse his years-long courtship of Assad and go all-in on the regime-change project for Syria, the dilemma that Putin faced in trying to balance Moscow’s relations with the two now-warring parties sharpened dramatically.

For any Russian leader, the country’s relationship with Turkey is important. For Putin, its numerous dimensions have included not only the potential for splitting NATO but also for riling the West in other ways, and the need (in a time of uneasy relations with Ukraine) for Russia to maintain good relations with as many other Black Sea neighbors as possible.

But Russia’s position in Syria also remains crucial. In summer 2015, the Russian military speedily built and equipped the advanced air-force base at Khmeimim, south of Lattakia. Together with the Russian naval base at Tartous, Khmeimim represents the most significant overseas base-complex maintained by the armed forces of Putin’s resurgent Russia. Within Syria, Russia wields considerable political-diplomatic heft, as well as military heft. Over the past few years, its diplomats have helped Assad negotiate de-escalation (surrender) deals with oppositionists in numerous parts of the country, enabling his government to reassert control of the vast majority of the country’s people.

At the global level, Russia has been less able to aid the Syrian government. Russia was unable to prevent Pres. Trump from throwing his support behind Israel’s annexation of Syria’s Golan. It has failed to break the stranglehold that U.S. sanctions have placed on Syria’s ability to rebuild from the destruction of the civil war. And though it worked intensively with the UN’s Special Representative for Syria, Geir Pedersen, to convene a broad gathering in Geneva last October, to negotiate a final resolution of the internal differences among Syrians that sparked the civil war, that initiative failed to gain legs.

Nevertheless, as the events in Moscow on March 5 revealed, Putin’s Russia has continued to increase its power with the tangled geopolitics of Syria. In the Moscow Agreement, Putin and Erdogan vowed to continue to support both the all-Syria peace process and the fight against terrorists in Syria. Americans and everyone else who wants to see an end to the misery the civil war has inflicted on Syria’s people should support them.