By Laila Bassam and Tom Perry
BEIRUT (Reuters) - At a meeting in Moscow in July, a top Iranian general unfurled a map of Syria to explain to his Russian hosts how a series of defeats for President Bashar al-Assad could be turned into victory - with Russia's help.
Major General Qassem Soleimani's visit to Moscow was the first step in planning for a Russian military intervention that has reshaped the Syrian war and forged a new Iranian-Russian alliance in support of Assad.
As Russian warplanes bomb rebels from above, the arrival of Iranian special forces for ground operations underscores several months of planning between Assad's two most important allies, driven by panic at rapid insurgent gains.
Soleimani is the commander of the Quds Force, the elite extra-territorial special forces arm of Iran's Revolutionary Guards, and reports directly to Iran's Supreme Leader, Ayatollah Ali Khamenei.
Senior regional sources say he has already been overseeing ground operations against insurgents in Syria and is now at the heart of planning for the new Russian- and Iranian-backed offensive.
That expands his regional role as the battlefield commander who has also steered the fight in neighboring Iraq by Iranian-backed Shi'ite militia against Islamic State.
His Moscow meeting outlined the deteriorating situation in Syria, where rebel advances toward the coast were posing a danger to the heartland of Assad's Alawite sect, where Russia maintains its only Mediterranean naval base in Tartous.
"Soleimani put the map of Syria on the table. The Russians were very alarmed, and felt matters were in steep decline and that there were real dangers to the regime. The Iranians assured them there is still the possibility to reclaim the initiative," a senior regional official said. "At that time, Soleimani played a role in assuring them that we haven't lost all the cards."
Three senior officials in the region say Soleimani's July trip was preceded by high-level Russian-Iranian contacts that produced political agreement on the need to pump in new support for Assad as his losses accelerated.
Their accounts suggest planning for the intervention began to germinate several months earlier. It means Tehran and Moscow had been discussing ways to prop up Assad by force even as Western officials were describing what they believed was new flexibility in Moscow's stance on his future.
Before the latest moves, Iran had aided Assad militarily by mobilizing Shi'ite militias to fight alongside the Syrian army, and dispatching Iranian Revolutionary Guards Corps officers as advisors. A number of them have been killed.
Russia, an ally of Damascus since the Cold War, had supplied weapons to the Syrian army and shielded Damascus diplomatically from Western attempts to sanction Assad at the United Nations.
Their support did not prevent rebels - some of them backed by Assad's regional foes - from reducing Assad's control of Syria to around one fifth of its territory in a four-year-long war estimated to have killed 250,000 people.
The decision for a joint Iranian-Russian military effort in Syria was taken at a meeting between Russia's foreign minister and Khamenei a few months ago, said a senior official of a country in the region, involved in security matters.
"Soleimani, assigned by Khamenei to run the Iranian side of the operation, traveled to Moscow to discuss details. And he also traveled to Syria several times since then," the official said.
The Russian government says its Syria deployment came as the result of a formal request from Assad, who himself laid out the problems facing the Syrian military in stark terms in July, saying it faced a manpower problem.
Khamenei also sent a senior envoy to Moscow to meet President Vladimir Putin, another senior regional official said. "Putin told him 'Okay we will intervene. Send Qassem Soleimani'. He went to explain the map of the theater."
RESIDENT IN DAMASCUS
Russian warplanes, deployed at an airfield in Latakia, began mounting air strikes against rebels in Syria last week.
Moscow says it is targeting Islamic State, but many of Russia's air strikes have hit other insurgents, including groups backed by Assad's foreign enemies, notably in the northwest where rebels seized strategically important towns including Jisr al-Shughour earlier this year.
In the biggest deployment of Iranian forces yet, sources told Reuters last week that hundreds of troops have arrived since late September to take part in a major ground offensive planned in the west and northwest.
Around 3,000 fighters from the Iranian-backed Lebanese group Hezbollah have also mobilized for the battle, along with Syrian army troops, said one of the senior regional sources.
The military intervention in Syria is set out in an agreement between Moscow and Tehran that says Russian air strikes will support ground operations by Iranian, Syrian and Lebanese Hezbollah forces, said one of the senior regional sources.
The agreement also included the provision of more sophisticated Russian weapons to the Syrian army, and the establishment of joint operations rooms that would bring those allies together, along with the government of Iraq, which is allied both to Iran and the United States.
One of the operations rooms is in Damascus and another is in Baghdad.
"Soleimani is almost resident in Damascus, or let's say he goes there a lot and you can find him between meetings with President Assad and visits to the theater of operations like any other soldier," said one of the senior regional officials.
Syria's foreign minister said on Monday that the Russian air strikes had been planned for months.
(Writing by Tom Perry; Editing by Peter Graff)