For Vladimir Putin, Russia's military build-up in Syria is a potential diplomatic trump card and a handy way of diverting attention from Ukraine's frozen conflict. But it was a panicky realization that the Syrian government was being turned over on the battlefield that tipped the Kremlin's hand.
When it saw several months ago that Syrian government forces were retreating on several fronts at a rate that threatened President Bashar Assad, its closest Middle East ally, the Kremlin quietly decided to dispatch more men, weaponry and armor, diplomats and analysts told Reuters.
"The situation at the front was pretty serious if not critical," said Ivan Konovalov, director of the Center for Strategic Trend Studies in Moscow. "Military assistance was needed on a larger scale; Russia responded."
Two diplomats who track Syria closely agreed, saying the Kremlin had watched government reversals against militant groups such as Islamic State with growing alarm.
"The Russians are seeking to limit the damage," said one.
Andrew Weiss, a Russia expert in two previous U.S. administrations, said the Kremlin had feared "the regime was on the ropes."
Russia sees Assad, someone Putin has staunchly supported throughout a conflict that has lasted over four years and killed more than 250,000 people, as a long-standing Kremlin ally and a bulwark against radical Islam.
If he were toppled, Moscow worries many of the same militants fighting against him -- thousands of whom hail from Russia and the former Soviet Union -- would return home to stir up problems on Russia's southern flank in the predominantly Muslim Caucasus.
"Perhaps Bashar Assad is a son of a bitch in the eyes of the global community," wrote commentator Oleg Odnokolenko in the Nezavisimaya Gazeta daily this week. "But .. for as long as his troops stand up to IS (Russian) military support is guaranteed."
A Western security source, speaking on condition of anonymity, said Moscow was making clear it is not prepared to allow Assad to fall.
"The Russians are sending a signal: Assad will remain in power for the time being."
That position puts Moscow at odds with the United States, which has been leading an air war against Islamic State fighters in Syria and Iraq since last year, but which says Assad's presence makes the situation worse. Washington's allies back groups fighting against both Islamic State and Assad.
The U.S. and Russian defense chiefs spoke on Friday for the first time in over a year, discussing the crisis in Syria as Moscow's build-up raised the prospect of the former Cold War foes encountering each other on the battlefield.
Evidence of the Kremlin's push grows by the day, with U.S. officials spotting tanks, artillery pieces, helicopters and more frequent and larger deliveries of military hardware.
Putin, who remains popular at home despite a deepening economic crisis, will have to tread carefully on Syria though. Polls suggest ordinary Russians are fed up of hearing about the relatively becalmed Ukraine conflict and are unlikely to want to see a major intervention in the Middle East.
So far, the build-up, which has not generated any Russian body bags, has caused few ripples among voters more focused on the weakness of the ruble and rising prices. Nor are there signs that the Russian army is over-stretching itself.
For Moscow, Syria is of vital strategic importance.
Its naval base at Tartous is its sole installation in the Mediterranean, and protecting it is a strategic objective. Assad's government has historically been one of its best clients for arms sales, and its military presence there underpins its influence in the region.
If Assad fell, that influence could vanish overnight and Putin's authority on the world stage, already weakened by his country's actions in Ukraine, would be further dented.
"The Russians are also afraid that if they are not on the spot in Syria and the regime falls, they will not be part of the solution," said one of the two diplomats.
The Kremlin has played down the build-up in Syria, saying only that it continues to honour its longstanding policy of supplying Assad with arms and advisers to help him defeat Islamist militants. It has denied reports its forces are taking part in combat operations alongside Syrian troops, but has said it would consider any request if it was made.
An airfield near the Assad stronghold of Latakia appears to be at the heart of the Kremlin's plans.
According to the White House, the Russians have recently widened the runways and brought in new air traffic control systems and components for air defense systems.
The air defenses in particular have raised eyebrows in the United States, since Islamic State and other militants have no aircraft, so the only potential enemy planes flying overhead are those of Washington and its allies.
The airfield could in time be converted into a fully-fledged airbase, something Russian military commanders have not ruled out. It has been receiving about two military cargo planes a day for some time, say U.S. officials. The planes use Iranian and Iraqi airspace to get there.
U.S. officials say Russia has sent battle tanks, artillery and other equipment to reinforce the airfield along with around 200 marines.
Russia's close ties to the Syrian government date back to the Soviet era when it counted Bashar's father, Hafez Assad, as one of its allies. Even before the latest build-up, it had teams of military advisers and trainers on the ground.
Analysts say Russian personnel are now thought to be deployed at six separate locations, including in Damascus.
There are signs that Moscow's stepped-up assistance is having an effect.
The Syrian military has recently started using new types of air and ground weapons supplied by Russia, a Syrian military source told Reuters on Thursday, and there have been unconfirmed reports of the Syrian air force striking targets with greater force and precision than previously.
Moscow's plan, say a number of Syria-watchers, is to help forces loyal to Assad hold and retake ground and to reinforce the heartland of members of his Alawite sect, so that if he is pushed from Damascus Russia can help him dig in there.
"Moscow's Plan A I think is to help Bashar to hold out in Damascus," said Dmitry Trenin, a former colonel in the Russian army and director of the Carnegie Moscow Center.
"Plan B would be if Damascus was lost to IS and Assad had to redeploy to Latakia. Then the Russians would help him there. They would be playing for the future composition of Syria."