In recent weeks, the battle for Idlib in northwest Syria has entered a new phase. Syrian regime forces, backed by Russia and Iran, have pushed to capture the strategic M4 and M5 highways, which link respectively the city of Latakia and the capital, Damascus, to Aleppo.

The advance of the Syrian forces accompanied by an intensive aerial bombardment campaign over the last remaining stronghold of the Syrian opposition has killed dozens of civilians and opposition fighters, as well as 13 Turkish soldiers, and sent hundreds of thousands of civilians fleeing towards the Turkish border. This has pushed Ankara to take action.

The Turkish military has sent several convoys into Syrian territory, reinforcing its observation posts in the northwest, which have been overrun by Syrian regime forces, and setting up new ones in opposition-controlled areas.

Turkey fears that Russia's ultimate objective is to besiege the armed opposition and cut its main supply routes from Turkish territory - a development which it desperately wants to avoid.

With its back to the wall, Ankara is now weighing its options to prevent a complete defeat of its Syrian allies and with them its Syria venture.

Last de-escalation zone

Idlib is the last of the four so-called de-escalation zones agreed by Russia, Iran and Turkey in 2017 which has still not been taken over by the regime. The other three - Eastern Ghouta, near Damascus, Deraa and Quneitra provinces in the south, and the Rastan and Talbiseh enclave in Homs province - were attacked and captured by regime forces one after the other in the span of a year.

After every takeover, tens of thousands of civilians and fighters who did not want to stay under regime rule were allowed to leave for Idlib, adding to the growing population of IDPs.

In 2018, Turkey managed to save Idlib from the fate of the other three by concluding an agreement with Russia in Sochi to establish a demilitarised zone in Idlib. In return, Turkey pledged to disarm and remove Hay'et Tahrir al-Sham (HTS) - an armed group previously linked to al-Qaeda - from the de-militarised area. The two sides also agreed to reopen the M4 and M5 for trade and movement.

The agreement was never implemented in its entirety, however. Turkey could not force HTC to honour it, while Moscow did not stop the Syrian regime forces from attacking the safe zone, having always thought of the demilitarised zone as a temporary solution and ultimately aiming for all Syrian territories to come back under regime control.

In this sense, the escalation in Idlib was inevitable. But unlike the takeovers of the other de-escalation zones, the fall of Idlib would be disastrous for Turkey. It would mean a total defeat of the Syrian opposition and its exclusion from negotiations of a final solution for post-war Syria. By extension, Turkey, the main backer of the opposition, would also be sidelined and have no say in future negotiations, which would be a major diplomatic loss given years of Turkish engagement in the conflict.

Furthermore, a regime takeover of Idlib would result in the expulsion of some three million civilians towards Turkey's borders or the small border areas it controls in northern Aleppo province. Given growing domestic hostility towards Syrian refugees, Turkey cannot afford to accommodate more Syrians on its territory.

The Turkish government is also under huge domestic pressure to retaliate after the killing of 13 Turkish soldiers by Syrian regime forces. Turkey will be criticised at home if its forces are forced to withdraw from the observation posts currently under siege by the Syrian regime.

Turkish-Russian relations

Although Turkey rejects a military solution in northwest Syria, it also cannot risk a confrontation with Russia. It paid a heavy price last time it clashed with Russia in 2015 when the Turkish military downed a Russian fighter jet near the Syrian-Turkish border. In response, the Kremlin banned imports of Turkish goods and discouraged its citizens from vacationing in Turkey, which took a heavy toll on the Turkish economy.

At the same time, neither the EU, nor the US backed Turkey in its escalation against Russia. What is more, both were slow to condemn the coup attempt against President Recep Tayyip Erdogan in July 2016.

Feeling isolated by its traditional allies, Ankara had to put massive efforts, including a public apology by Erdogan, into repairing relations with Moscow.

Today, Turkey's ties with Russia have grown stronger and are now more important to the Turkish government than they were in 2015. Russia is a major trading partner (bilateral trade exceeds $25bn annually) and, more importantly, Turkey's top oil and gas supplier - its share of the Turkish market having increased after the US imposed sanctions on Iranian energy exports.

Turkey is also becoming a transit hub for the export of Russian gas to Europe. Last month, Erdogan and Russian President Vladimir Putin inaugurated the Turk Stream, a gas pipeline crossing the Black Sea from Russia to Turkey, which is meant to deliver gas to southeast Europe. Turkey also hopes to enlist Russian support in the growing tensions over gas drilling in the East Mediterranean, especially after the US signalled its support for Greece.

Diplomatic cooperation between Turkey and Russia has also intensified in Libya, where the two countries are supporting opposing sides. Ankara and Moscow have been actively engaged in trying to negotiate a ceasefire between the UN-recognised Government of National Accord and renegade General Khalifa Haftar.

Turkish-Russian cooperation has also intensified in the field of defence. Turkey bought an S-400 missile defence system from Russia, despite the opposition of its NATO allies, and has also discussed the possibility of purchasing Russian Su-35 and Su-57 fighter jets.

Three scenarios

Under pressure to stop the advance of the regime in Idlib and at the same time to preserve its relations with Russia, Turkey has very little room for manoeuvre. At this point, there appear to be three possible scenarios.

The first and the most favourable scenario for Turkey is Russia agreeing to uphold the de-escalation zone agreement in Idlib and ordering the regime forces to return to the positions they held before its latest offensive. This could be combined with a revival of the political process and resumption of the meetings of the constitutional committee, tasked with drafting amendments to the Syrian constitution agreed upon by the regime, the opposition and the international community.

Although Turkey has tried to push for such a settlement by threatening military action if the Syrian regime did not pull back, the likelihood of it happening is very slim.

The second scenario is Turkey accepting the new realities on the ground and allowing the Syrian regime to control the M4 and M5 highways, but using force to forestall any further advance. It could seek to establish "a safe zone" in Idlib by setting up reinforced defence positions along the frontline and supplying the Syrian opposition with heavy weapons, especially anti-aircraft missiles. It seems Ankara has already adopted this policy given that two regime helicopters were downed in Idlib with anti-aircraft weapons.

The third scenario - and one which Turkey wants to avoid - is an escalation with Russia. The presence of anti-aircraft weapons on the ground raises the risk of a Russian aircraft being shot down. The Turkish military is likely taking precautions to avoid such a dangerous development, but given massive deployments on the ground, it is the closest it has been since 2015 to a confrontation with Russian forces.

While Turkey will continue to tread carefully on the Idlib issue, what happens next depends a lot on what the US decides to do. So far Washington has been sending mixed signals to Ankara. Secretary of State Mike Pompeo expressed his support for Turkey, and so did Special Representative for Syria Engagement James Jeffrey. The Pentagon, however, responded by saying that "no… agreement was made" on the US taking more concrete steps in Idlib.

But just as Russia has been trying to push Turkey and its NATO allies further apart, the US may decide to take the opportunity to do the same with the Turkish-Russian rapprochement by backing a Turkish operation in Idlib.

Either way, major decisions will have to be made in Ankara, Moscow and Washington in the coming weeks - decisions which may determine the next phase of the Syrian conflict.

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