Russia and Turkey agreed to ensure Kurdish forces withdraw from areas close to Syria’s border with Turkey and to launch joint patrols, in a deal hailed as “historic” by President Recep Tayyip Erdogan.

After marathon talks in Russia’s southern city of Sochi, Erdogan and Russia’s President Vladimir Putin announced the deal just hours ahead of a deadline for Turkey to restart its assault on Syria’s Kurds.

The agreement will see Turkey preserve control of an area 32 kilometers deep into Syria seized during the operation.

From today, Russian Military Police and Syrian Border Guards will “facilitate the removal” of Kurdish fighters and their weapons from within 30 kilometers of the entire border.

According to a text of the agreement released after the talks, this withdrawal must be finalized within 150 hours.

Russian and Turkish forces will then begin joint patrols along the Turkish-controlled zone.

Putin said the decisions were “very important, if not crucial, to allowing us to resolve the acute situation on the Syrian-Turkish border.”

Erdogan had earlier threatened to resume Ankara’s military offensive against Kurdish forces in Syria if they did not withdraw as agreed under a US-brokered deal.