In July 2015, the defeat of Syrian President Bashar Assad appeared imminent.
His troops, overstretched and exhausted, had lost too many men, and a string of humiliating defeats meant the government controlled only a quarter of the country.
Two months later, Russian warplanes streaked through Syria's skies, hurling bombs at Assad's adversaries and starting a reversal of fortune that, more than two years later, has forced most of those enemies to accede that he will remain.
That was the backdrop to Russian President Vladimir Putin's surprise visit to a Syrian air base on Monday, where he met with Assad and declared that Moscow would begin a drawdown of troops following what the Kremlin said was the defeat of Islamic State.
"You are returning with victory to your native homes, to your relatives, parents, wives, children, friends," Putin said in an address to Russian troops at the Hemeimeem air base shown on state television. "The motherland is waiting for you."
Russian Defense Minister Sergei Shoigu and the commander of Russia's military forces in Syria, Col. Gen. Sergey Surovikin, were also in attendance at the base southeast of Latakia.
The troop withdrawal announcement came a week after the Russian Ministry of Defense said that it had defeated Islamic State and that there were no remaining enclaves left in Syria under the militant group's control.
In his speech at the base on Monday, Putin said Moscow would begin bringing home a "significant part" of its troops, but left room for Russian troops to strike once more if Islamic State tried to return.
"If terrorists raise their heads again, we will strike at them with such blows as they have never seen," he said.
Assad was effusive in his praise of Russia's support.
"Future generations that will read of this war will not differentiate between the Syrian martyr and the Russian martyr," Assad said. "And the sacrifices of the heroes from both sides was a manifestation of the noblest battle in the confrontation of terrorism."
Assad added that Russian pilots have been "in the air all the time," according to the Russian state news agency Tass.
"Thanks a million," he added.
Monday's visit was Putin's first to Syria since Russia's decisive intervention more than two years ago. Russia has two bases in Syria, the air base at Hemeimeem and a naval base at Tartus (both will remain operational and in Russia's hands), from which Russia has conducted airstrikes against groups opposed to Assad's government, including the Syrian National Coalition and Islamic State.
Putin's announcement Monday was not the first time he has said Russian troops would be leaving Syria.
Last month, during a surprise visit by Assad to Russia's Black Sea resort of Sochi, Putin announced that the Russian military campaign in Syria was over and that its troops would be leaving Syria. During that meeting, Assad thanked Putin for "saving" his country.
Some analysts believe Monday's announcement may be more likely to be followed by actual troop movement than the previous announcements, as the Syrian conflict moves into what Assad in his speech said was "the second phase of combating terrorism."
Islamic State has largely been defeated in Syria and, thanks to Russian military backing, Assad's government troops have prevailed against the other rebel opposition militias, said Leonid Issaev, an associate professor in the department of political science at the Higher School of Economics in Moscow. What comes next, he said, will be a political resolution to the Syrian civil war, and Russia wants to make sure it has a clear role of influence in a future Syria.
"It's very important for Putin to show to the international community that it's not Iran who has the most important presence in Syria, but that it's Moscow who plays a crucial role in Damascus," Issaev said.
"So, in that sense, it's realistic that we've finished the military campaign in Syria. Assad is the winner, he won this war in Syria" with Russian help, he added.
It is unclear how many Russian military advisors (the euphemistic catchall for special forces or private contractors) will remain in the country as Damascus continues its campaign to defeat the opposition it cannot neutralize with negotiations.
The rebels still control pockets of territory, especially near the country's borders. That includes Idlib province, held by Assad's most implacable foes.
Putin added that he hoped Iran and Turkey would be able to restore the peace in the country.
There is a domestic advantage as well to Putin's announcement. The Russian president said last week that he would seek reelection in March. A Russian military success in Syria bodes well for his prospects more than three months ahead of the election.
Putin made the stop in Syria on his way to meet Egyptian President Abdel Fattah Sisi for talks in Cairo.
Special correspondent Ayres reported from Moscow and Bulos from Beirut.
Ayres is a special correspondent.
12:05 p.m.: This article has been updated with additional quotes, background.