Russia and Turkey’s leaders announced Thursday they have reached a cease-fire agreement to begin at midnight in the northwestern Syrian region of Idlib.

The deal set up by Russian President Vladimir Putin and Turkish President Recep Tayyip Erdogan also established a security corridor along an east-west highway in Idlib.

An offensive by Syrian dictator Bashar al-Assad and his Russian-backed forces forced more than 1 million civilians to flee toward the Turkish border, while Turkey already hosts 3.5 million Syrian refugees. At the same time, 36 Turkish soldiers were killed in the crossfire.

Turkey, which backs opposition rebels, responded by attacking Syrian troops.

Russia's President Vladimir Putin, right, and Turkish President Recep Tayyip Erdogan shake hands after a joint news conference followed six-hour talks in the Kremlin, in Moscow, Russia, Thursday, March 5, 2020. (Presidential Press Service via AP, Pool)

Russia's President Vladimir Putin, right, and Turkish President Recep Tayyip Erdogan shake hands after a joint news conference followed six-hour talks in the Kremlin, in Moscow, Russia, Thursday, March 5, 2020. (Presidential Press Service via AP, Pool)

Putin said he hoped the agreement would serve as a “good basis for ending the fighting in the Idlib de-escalation zone, put an end to the suffering of civilian population and contain a growing humanitarian crisis.”

BRAWL BREAKS OUT IN TURKEY'S PARLIAMENT OVER SYRIA INVOLVEMENT, ERDOGAN MEETS WITH PUTIN

After a devastating nine-year civil war, Syria’s recent offensive campaign to reclaim rebel strongholds in Idlib has exacerbated the country’s refugee crisis to one of its most dire points.

The agreement appears to allow Russia through the Syrian government to secure control over strategic highways. For Turkey’s interests, Assad appeared to agree to back off his push to reclaim control over all of the Idlib province, the last opposition-controlled region that borders Turkey.

In a previous test of Russia-Turkey relations, when Turkey downed a Russian warplane in 2015, Russia enacted sweeping economic sanctions, cutting the flow of tourists to Turkey and banning most Turkish exports. Turkey could not handle the costly crisis, much less a military conflict with a nuclear power, and backed off. But this time, Moscow needs Ankara as a partner in Syrian settlement, and Russia’s supply routes for its forces cross the Turkish Straits.

TURKEY DOWNS 2 SYRIAN WARPLANES AS TENSIONS SOAR, OFFICIALS SAY 

Erdogan said he and Putin agreed to help refugees return to their homes. More than 900,000 have been displaced by the fighting since Assad’s forces began their offensive in December, backed by Russian airstrikes on schools, hospitals and homes.

Until the latest crisis, Putin and Erdogan had managed to avoid conflict in Syria even though Moscow backed Assad while Ankara supported the rebels. Syria’s offensive in Idlib led Turkey to send in thousands of troops.

Putin offered his condolences to Erdogan over the Turkish military losses but noted that Syrian troops had also suffered heavy casualties: 60 dead since the start of February.

"The world’s eyes are on us," Erdogan had said. “The steps we will take, the right decisions we will take here today will help ease [concerns in] the region and our countries.”

In response to the 1 million new refugees making their way toward Turkey, Erdogan opened his country’s gateway to Europe.

“It’s done, the gates are open,” he said Monday, adding that Western leaders were calling him to reverse the border opening. “You will have your share of this burden now.”

CLICK HERE TO GET THE FOX NEWS APP

Soon, “the number of people going to the border will be expressed in millions,” he added. He has demanded more help from Western nations in dealing with the fallout from violence in Syria.

The Associated Press contributed to this report.