Russia and Turkey have forged a surprise deal which they claim will stave off an offensive to retake Syria’s last remaining opposition stronghold, agreeing to establish a demilitarised zone between government and rebel forces and joint patrols to enforce the compromise.

Turkey’s president, Recep Tayyip Erdogan, meeting with Russian president Vladimir Putin in the Black Sea resort city of Sochi, said the compromise would prevent the loss of civilian lives in Syria’s northwest Idlib province.

“With this memorandum of understanding, I believe we have prevented a major humanitarian crisis in Idlib,” Mr Erdogan said in a statement.

Mr Putin, the primary patron of the Syrian government of president Bashar al-Assad, said the agreement sets up a mechanism for ridding Idlib of extremist rebel fighters, some of who were inspired by al-Qaeda. “Russia and Turkey reiterated their commitment to continue anti-terrorism efforts in Syria in any of its forms or manifestations,” he said, according to the Tass news agency.

Syria has been mired in an intense civil war for seven years. Mr Assad has turned the war around with the help of Iranian-organised ground forces and Russian air power. The Sochi deal further delays a much-anticipated offensive by the Syrian regime and allied Iranian-backed militias as well as Russian warplanes to retake Idlib, which has been in rebel hands for years.

The deal calls for a 15km to 20km demilitarised zone to be established by 15 October between opposition forces and government-controlled areas clear of what Mr Putin described as “radically inclined fighters,” especially those belonging to the former al-Qaeda affiliate in Syria, now called Hayat Tahrir al-Sham (HTS).

Fears for 3m people in rebel-held Idlib ahead of regime offensive Show all 13 1 /13 Fears for 3m people in rebel-held Idlib ahead of regime offensive Fears for 3m people in rebel-held Idlib ahead of regime offensive A Syrian protester waves a flag of the opposition as during a protest against the regime and its ally Russia, in the rebel-held town of Maaret al-Numan in the north of Idlib province AFP/Getty Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrian rebel fighters from the recently-formed "National Liberation Front" stand guard over a trench as rebels prepare defensive positions in anticipation for an upcoming government forces offensive AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrians chant slogans and wave flags of the opposition as they protest against the regime and its ally Russia, in the rebel-held town of Maarrat al-Numan in the north of Idlib province on August 31, 2018. - Its hospitals are battered, residents heavily dependent on aid and escape routes to neighbouring Turkey sealed. If attacked by government forces, Syria's rebel-held Idlib is poised for a humanitarian calamity. (Photo by Zein Al RIFAI / AFP)ZEIN AL RIFAI/AFP/Getty Images ZEIN AL RIFAI AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrian rebel fighters pile-up sandbags AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrians chant slogans and wave flags of the opposition as they protest against the regime and its ally Russia, in Binnish in Syria's rebel-held northern Idlib province on August 31, 2018. (Photo by Muhammad HAJ KADOUR / AFP)MUHAMMAD HAJ KADOUR/AFP/Getty Images MUHAMMAD HAJ KADOUR AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive A Syrian rebel fighter looks through an embrasure in a make-shift bunker AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive A Syrian protester chants slogans as he waves a flag of the opposition as he protest against the regime and its ally Russia, in the rebel-held town of Maaret al-Numan in the north of Idlib province on August 31, 2018. - Its hospitals are battered, residents heavily dependent on aid and escape routes to neighbouring Turkey sealed. If attacked by government forces, Syria's rebel-held Idlib is poised for a humanitarian calamity. (Photo by Zein Al RIFAI / AFP)ZEIN AL RIFAI/AFP/Getty Images ZEIN AL RIFAI AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrian rebel fighters walk through a trench AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive A Syrian protester waves a flag of the opposition AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive A Syrian rebel fighter stands guard over a trench AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive A Syrian rebel fighter from the recently-formed "National Liberation Front" walks through a trench as rebels prepare defensive positions in anticipation for an upcoming government forces offensive, in the countryside of the rebel-held northern Idlib province on August 31, 2018. - In recent days, both the government and its ally Russia have stepped up their rhetoric against the rebel presence in Idlib as they gear up for an assault, which could be the last major battle of the civil war that has torn the country apart since 2011. (Photo by OMAR HAJ KADOUR / AFP)OMAR HAJ KADOUR/AFP/Getty Images OMAR HAJ KADOUR AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrians chant slogans and wave flags of the opposition as they protest against the regime and its ally Russia, in Binnish in Syria's rebel-held northern Idlib province on August 31, 2018. (Photo by Muhammad HAJ KADOUR / AFP)MUHAMMAD HAJ KADOUR/AFP/Getty Images MUHAMMAD HAJ KADOUR AFP/Getty Images Fears for 3m people in rebel-held Idlib ahead of regime offensive Syrian rebel fighters from the recently-formed "National Liberation Front" walk through a a trench as they prepare defensive positions in anticipation for an upcoming government forces offensive, in the countryside of the rebel-held northern Idlib province on August 31, 2018. - In recent days, both the government and its ally Russia have stepped up their rhetoric against the rebel presence in Idlib as they gear up for an assault, which could be the last major battle of the civil war that has torn the country apart since 2011. (Photo by OMAR HAJ KADOUR / AFP)OMAR HAJ KADOUR/AFP/Getty Images OMAR HAJ KADOUR AFP/Getty Images

By 10 October, all heavy weaponry including tanks, Katyusha rocket systems, and mortars will be removed from this area, according to the deal as described by Mr Putin. Joint units of Turkish military and Russian military police will patrol the buffer zone, and transport links cut off by the war will be restored by the end of the year.

Experts pointed out that the deal could easily collapse, as have previous such Syria settlements.

In the past Russia has struck numerous deals with Turkey and the rebel forces it supports to de-escalate the situation in Syria, only to slowly allow such compromises in places like Aleppo or the eastern Ghouta suburbs of Damascus to collapse, often using the excuse that extremists on the other side were not included in the deal, or that rebels were violating its terms.

Airstrikes in in Idlib, northwestern Syria

“Unfortunately, the track records of all the participants really prepare us to expect the worst,” said Thanassis Cambanis, a senior fellow at The Century Foundation, a New York think tank. “Around Aleppo and Ghouta there were various ceasefires. The gaping hole is that ‘terrorists’ are all fair game. Putin has endorsed a lot of truces, and then Russia proceeded to bomb groups it defines as terrorists that it says weren’t part of the deal.”

This truce might be different. Mr Putin’s own credibility is at stake, having made the deal in a high-profile summit with Mr Erdogan. Turkey and Russia are increasingly becoming trade and diplomatic partners. Russia is building Turkey’s first nuclear reactor.

The Kremlin also sees the strains between Turkey and western countries as an opportunity to divide and weaken the Nato alliance, to which Turkey provides the second largest number of troops.

But Iran, its allied militias, and the Assad government also are wild cards. In recent months it has become clear to analysts and diplomats that Russia exercise is minimal if any control over the actions of the various ground forces upholding Mr Assad’s rule, including Iraqi Shia militias that have on occasion even fought against Syrian forces over turf.

On Monday, Mr Putin said he would get Damascus to endorse the Sochi deal. “In general, the Syrian leadership supports this approach,” he said. “We will hold additional consultations with the Syrian authorities soon.”

The estimated thousands of hardcore jihadi fighters in Idlib pose another threat to the Sochi deal. Unlike international extremist groups, they mostly have no aspirations beyond defeating Assad in Syria, so have nowhere else to go, and will likely decide they do not wish to leave the buffer zone. They are also some of Syria’s fiercest fighters, battle-hardened over years of gruelling warfare.