Turkey and Russia have agreed what they called a “historic” deal over military action against Kurds in northern Syria after a marathon diplomatic meeting.
Turkey has been launching an offensive against Syria’s minority Kurdish group near the border.
Russia, a military ally of Syria’s president, had deployed troops to the region in response.
The deal says that Russia has agreed to allow Turkey’s operation, removing the risk of conflict between the two sides.
It came just ahead of the expiry of a ceasefire between Kurdish fighters and Turkish forces, and it is not yet clear whether the Kurdish militias will agree to the terms laid down by Russia and Turkey.
Turkey considers the Kurdish People’s Protection Units (YPG) militia to be a terrorist organisation.
The ceasefire, brokered by the United States, expires at 22:00 (19:00 GMT). Shortly beforehand, the YPG said they had complied with the terms of the US-brokered deal.
But the new deal agreed by Turkey with Russia has given Kurdish fighters extra time to withdraw.
From noon on Wednesday, the Kurdish fighters would have another 150 hours to leave the border region, withdrawing to a depth of 30km (19 miles) from the border – a so-called “safe zone”.
The area affected is a 120km-long strip between the towns of Ras al-Ain to Tal Abyad, where the Turkish operation is taking place.
But Mr Erdogan had reportedly wanted all 440km of the border to be part of the safe zone.
The statement from Russia and Turkey says that Kurdish forces “will be removed” from the towns of Manbij and Tal Rifat – both of which lie outside the operation area.
It also says Russia and Turkey will conduct joint patrols outside the operation area.