Putin and Erdogan announced the ceasefire at a press conference after almost six hours of talks in the Kremlin.
Under the deal, Russia and Turkey will ensure a ceasefire begins from midnight Thursday along the existing line of contact in Idlib, where Syrian government forces, backed by Moscow, have been fighting with rebels supported by Turkey.
Russian Foreign Minister Sergey Lavrov, who read the agreement at the press conference, said that Turkish and Russian troops will also begin joint patrols along Idlib's M4 highway, which has been at the center of recent fighting.
Six-kilometer “security belts” will also be created along the areas north and south of the highway, Lavrov said, with the details of those zones to be determined by Russia and Turkey’s defense ministries.
The agreement between Putin and Erdogan signals that Russia and Turkey have once again found an accommodation over Syria, after weeks of an increasingly dangerous escalation in Idlib, where Turkey has sought to blunt a Russian-backed offensive by Syrian government forces.
The conflict has brought Russian and Turkish forces into increasingly direct conflict, as Turkey has committed artillery and more ground troops to aid the rebels in the province, which is the last major area they still hold in Syria.
The crisis came to a head last week when more than 30 Turkish troops were killed in an airstrike in Idlib. Since then, Turkey has been conducting an intense bombardment against Syrian government troops, inflicting significant losses on them and threatening to force them to retreat.
The fighting has triggered an international diplomatic crisis, as Western countries have become alarmed by the humanitarian disaster in Idlib, where hundreds of thousands of civilians have been forced to flee in the largest exodus of people in Syria's nine-year civil war.
The conflict over Idlib has threatened to unravel the understanding between Russia and Turkey over Syria and to spoil the warm relations Putin and Erdogan have sought to foster between their governments.
After the airstrikes that killed the Turkish troops last week, Turkey called an emergency meeting with NATO and began talks with the United States, even raising the prospect of seeking American missile defense systems to use over Idlib. Russia, while not intervening to halt the Turkish bombardment, moved some of its military police into strategic areas in the hope of deterring Turkish advances, and had reportedly rushed extra troops to Syria.
But on Thursday, Putin and Erdogan expressed warm words for each other and said they were determined Idlib would not damage relations between them.
“We don’t always agree on what is happening in Syria,” Putin said at the press conference. “But at the critical moments we always find an acceptable outcome.”
Erdogan also praised the level of relations between Russia and Turkey, which he said had allowed them to reach the agreement. He referred to Putin as “my dear friend” and blamed the conflict in Idlib on the regime of Syrian president Bashar al-Assad.
"We will not allow the forces of the regime to harm our relations with Russia," Erdogan said.
Erdogan said that Turkey retained the right to strike Syrian government forces if they continued their attacks.
Putin and Erdogan pledged to respect the so-called Sochi Agreement, which designated Idlib a “de-escalation zone,” and to seek a political solution to Syria’s war.
The deal comes as Western countries have expressed deepening alarm at the humanitarian crisis in Idlib, worried it could lead to a new refugee crisis as hundreds of thousands of civilians flee. Almost a million people have already been displaced since December, according to the United Nations.
Following the Turkish troops’ deaths last week Turkey said it would stop preventing Syrian refugees entering Europe, in a move intended to pressure European countries to act over Idlib. Since then hundreds of Syrians have gathered at Turkey’s border with Greece, which has prompted Greek authorities to close border crossings there as Greek police have roughly pushed refugees back.
Ahead of his meeting with Erdogan, Putin spoke by phone with European Council President Charles Michel, who said he urged Putin to reach a "sustainable ceasefire" and to work to end the suffering of civilians.
The agreement over Idlib appeared to echo a similar deal reached between Russia and Turkey last year to halt Turkey's invasion of northeastern Syria to drive out Kurdish authorities following the United States' withdrawal from the region. Putin and Erdogan brokered a deal there for Syrian government troops, accompanied by Russian forces, to move into areas previously overseen by Kurdish forces. Russia and Turkey now conduct joint patrols in the area.
The joint Russian-Turkish patrols in Idlib will take place along the M4 highway between the towns of Trumba, two kilometers west of the key town of Saraqeb, and Ain al-Habr, Lavrov said.
It remains to be seen how durable the ceasefire in Idlib will be. Syria’s government has previously vowed to recapture all of the country, and in an interview with Russian state TV before the deal was announced, Assad said again that Turkey must leave Syria and that regaining Idlib was critical to allowing the government to take back the eastern areas.
In the interview, however, Assad said he believed Turkey and Syria should try to restore normal diplomatic relations.