Image copyrightEPAImage caption President Putin (2nd L) and Syria’s President Assad (C) met at Hmeimim airbase in Syria on Monday

When Russia launched its military operation in Syria in 2015, the then US President Barack Obama predicted Moscow would get “stuck in a quagmire”.

His defence secretary, Ashton Carter, warned that Russia’s approach was “doomed to fail”.

Two years on, Russia appears to have proved the doomsayers wrong.

On a surprise trip to Syria this week, President Vladimir Putin told his troops they had fought “brilliantly” and could “return home victorious”. He ordered the withdrawal of a “significant part” of Russia’s military contingent.

So, mission accomplished for Moscow? It seems so.

The mission – at least as stated publicly by President Putin in September 2015 – was to fight “international terrorism”.

So-called Islamic State has, indeed, suffered defeat in Syria, although Western governments have criticised Moscow for also targeting the moderate Syrian opposition.

Image copyrightAFPImage caption Aleppo, October 2016: Russian and Syrian bombers pounded rebel-held parts of the city

But Russia’s campaign had another aim – to keep a key ally, President Bashar al-Assad, in power. That goal has been achieved.

As Russian military support for Damascus changed the facts on the ground in Mr Assad’s favour, the prospect of regime change in Syria retreated. The US, Turkey and Saudi Arabia had been demanding the Syrian leader’s removal as a prerequisite for peace. They no longer do so.

Mr Assad owes his political survival to President Putin, and that gives Moscow considerable influence in Syria.

The Russians will maintain two military bases in north-western Syria: Hmeimim near Latakia and a naval base in Tartus.

Read more on the Syria conflict:

Russian regional muscle

But Russia’s role in the Middle East is not limited to Syria. Moscow has emerged from this war as a major player across the region. It is:

Negotiating with Egypt to allow Russian military jets to use Egyptian airspace and bases

And across the Middle East Russian diplomacy is leading the push for a political settlement in Syria.

Media playback is unsupported on your device

Media captionFor the first time Russia fired cruise missiles from the Mediterranean

Russia’s rise in the Middle East contrasts with America’s image problem in the region. President Donald Trump’s recognition of Jerusalem as Israel’s capital has angered the Arab world and could end up damaging America’s reputation as a regional broker.

Following Moscow’s annexation of Crimea in 2014, Russia faced international isolation. But its military operation in Syria prevented that; whether they liked it or not, Western leaders were forced to sit down at the negotiating table and talk Syria with Russian leaders.

Propaganda for Putin

Crucially, the “quagmire” Washington predicted in Syria has not materialised.

Back in 2015 many Russians had feared that Syria could become a second Afghanistan: more than 10,000 Soviet soldiers were killed there in the 1980s in a decade-long military operation.

Russia has suffered casualties in Syria: officially 41 servicemen have been killed, while dozens more Russian private contractors are reported dead.

But with the Kremlin declaring victory and signalling a reduction in troop numbers, Syria no longer looks like becoming Mr Putin’s Afghanistan.

Image copyrightEPAImage caption Flying to Syria: Mr Putin reasserted Russian power and influence on the world stage

This week, Russia’s most popular daily paper, the pro-Kremlin Komsomolskaya Pravda, concluded that the Syrian conflict had strengthened Russia’s military.

“Tens of thousands of officers have received invaluable experience of the front line,” declared the newspaper.

“The war on terrorists was an exam, not only for our people, but for our arsenal. We tested dozens of weapons. As a result, foreign orders for Russian arms are rising fast.”

With the Kremlin leader standing for re-election in three months’ time, candidate Putin is likely to use the slogan “mission accomplished” to boost his support at the ballot box.

The timing of his Syria trip – less than a week after announcing his candidacy – had an air of electioneering about it.

And yet, despite the Kremlin’s talk of “routing terrorists” and its decision to bring home some of the troops, pockets of IS resistance remain in Syria. The conflict is not over yet.

And there is no guarantee that Russia’s efforts to achieve a political settlement will be successful.

The Syrian People’s Congress, which Moscow had planned to host this month in Sochi, has been postponed until next year. Differences remain between the key players in the peace process.

Declaring victory in a war does not necessarily bring it to an end. Especially such a bitter and complex conflict as the Syrian war.