Russian President Vladimir Putin held talks with his Turkish counterpart in Ankara on Monday for the last leg of a day-long diplomatic dash, during which he ordered the partial withdrawal of Russia's troops from the war-torn country.
Turkish President Recep Tayyip Erdogan met Putin at his presidential complex in Ankara for a closed-door meeting.
This is the eighth face-to-face meeting between Putin and Erdogan this year, a sign of the intensity of a relationship that had hit rock bottom in November 2015 when Turkey shot down a Russian war plane over Syria.
Putin was welcomed earlier in the day at Russia's Hmeimim airbase by Syria's President Bashar al-Assad on a surprise first visit to the country.
In a televised speech to Russian troops, Putin said he had ordered his Defence Minister Sergei Shoigu to start a partial withdrawal.
"I have taken a decision: a significant part of the Russian troop contingent located in Syria is returning home to Russia," he said at the base in Latakia Province, a government stronghold.
Russia first intervened in the conflict in 2015, staging air strikes in support of Assad which targeted both the Islamic State group (IS) and other jihadists as well as rebels fighting government troops.
Putin said the troops had helped the Syrian army crush the "most battle-ready group of international terrorists," apparently referring to IS.
"On the whole the task has been completed. And completed brilliantly."
- 'Our homeland thanks you' -
Putin said last month that efforts to end the war were entering a "new stage" as the focus shifted from military intervention to political reforms.
He said both Hmeimim and Russia's naval facility in Tartus would continue to function and warned that Russia would repel any new attacks by militants.
Putin made the Syria stopover, the first by a Russian head of state since president Dmitry Medvedev visited in 2010, en route to Egypt, where he met with Egyptian President Abdel Fattah al-Sisi, one of Ankara's prime foes in recent years.
Putin thanked the troops for defending Russia from terrorism and helping Syria remain a "sovereign independent state".
He said the conflict proved that Russia's armed forces, including intelligence officers, pilots, sailors, special forces, military police, sappers and military advisers, were on top form, and he also praised the country's defence industry.
"Our homeland thanks you, my friends," he said.
- 'Deep gratitude' -
Putin also held talks with Assad, who expressed his "deep gratitude" for Russia's role in the conflict.
"The Syrians will never forget what the Russian forces did," official Syria media quoted him as saying.
Putin said he would discuss Russia's efforts to convene Syria's political congress with the leaders of Egypt and Turkey, and then brief Assad.
While Turkey has backed the anti-regime opposition and Russia along with Iran is the main international supporter of Damascus, Putin and Erdogan have worked closely to resolve the Syrian conflict in recent months.
Ankara officially remains opposed to Assad staying in power in any transition but has notably toned down its rhetoric against the Syrian leader in recent months.
After talks, Erdogan said the next step to help resolve the Syrian conflict would be to hold a second summit in the Black Sea resort of Sochi "as soon as possible".
Last month Putin held a summit with Iran's President Hassan Rouhani and Erdogan in the city to discuss Syria.
Putin said at the beginning of 2018 that a congress of national dialogue should be held to seek a political solution for Syria, adding that he spoke to Assad about it.
- Pentagon scepticism -
Last week Putin announced he would be standing in the March presidential election that he is widely expected to win, and his lightning visit to Syria was likely to play well with Russian voters.
The commander of Russia's forces in Syria, Sergei Surovikin, said 23 Russian planes, two helicopters and military police would be returning to Russia soon, national television reported.
Asked how long the process of bringing back the contingent from Syria would take, Shoigu said: "They have already started coming back, we will see how it goes," Russian news agencies reported.
The Pentagon voiced scepticism about Putin's announcement, saying such declarations were not necessarily reflected by action.
The size of the Russian deployment in Syria is not known, but Pavel Felgenhauer, an independent Russian military expert, has told AFP that up to 10,000 troops and private contractors may have taken part in the conflict.
Putin had ruled out dispatching ground forces in Syria, making the air force the mainstay of Moscow's Syria campaign.
Around 40 Russian servicemen have reportedly been killed in Syria since Moscow's intervention. The Kremlin has acknowledged some of those deaths.
But the losses may be higher given the number of Russian troops and mercenaries believed to be in the country, observers say.
More than 340,000 people have been killed since the Syrian conflict broke out in March 2011 with protests against Assad's rule that sparked a brutal crackdown.