The Kremlin said the two leaders had spoken for three hours on their own before being joined by their officials.

Turkey and Russia agreed to a ceasefire deal on Thursday in Syria’s Idlib region; after their two leaders said after talks in Moscow to contain a conflict that has displaced nearly a million people in three months.

Russian President Vladimir Putin, standing next to his Turkish counterpart Tayyip Erdogan, said he hoped their agreement would lead to a halt of military action in Syria’s last major rebel stronghold in the northwest of the country.

“I express hope that these agreements will serve as a good basis for a cessation of military activity in the Idlib de-escalation zone (and) stop the suffering of the peaceful population and the growing humanitarian crisis,” Putin said.

Erdogan told reporters the truce would come into effect at midnight on Thursday. “We will work together to supply aid for the Syrians in need,” he said, adding that Turkey retained the right “to respond to all (Syrian) regime attacks in the field.”

Russia and Turkey back opposing sides in Syria’s nine-year conflict, with Moscow supporting President Bashar al-Assad and Turkey backing some rebel groups. Several previous deals to end the fighting in Idlib have collapsed.

The latest offensive in Idlib by Assad’s forces, backed by Russian airstrikes, sparked what the United Nations says may be the worst humanitarian crisis yet in a war that has driven millions from their homes and killed hundreds of thousands.

Putin and Erdogan agreed to establish a secure corridor near the M4 highway, which runs east to west through Idlib and hold joint patrols along the road from March 15.

In a joint statement, they said the corridor would stretch 6 km to the north and 6 km to the south of the M4 - forcefully advancing Russia’s presence further north into Idlib.

The Russian and Turkish defense ministers would agree on the parameters of the corridor within seven days.

The deal did not spell out - as Erdogan has repeatedly demanded - that Syrian forces withdraw to the edge of the Idlib “de-escalation zone,” around which Turkey has stationed a dozen military observation posts, most of them now surrounded by Russian-backed Syrian government forces.

The fighting, which raised the prospect of a direct clash between Russia and Turkey, has killed around 60 Turkish troops in the region since last month. Two hours after the joint announcement, Turkey’s defense ministry said two soldiers were killed after Syrian government forces opened fire in Idlib.

Putin expressed his regret to Erdogan about the recent killing of 34 Turkish troops in an airstrike, saying the Syrian military had not known of their location.