BEIRUT (Reuters) - An advisor to Syrian President Bashar al-Assad has said the six-year war is nearly over as foreign states cut backing for rebels, and vowed the government would confront any “illegitimate” forces, whether Turkish or American.

Slideshow ( 2 images )

Bouthaina Shaaban said the fact that Syria was staging the Damascus International Fair for the first time in the war “sends a message that the war has ended ... and we are at the start of the path towards reconstruction.”

With the help of Russian air power and Iran-backed militias, Damascus has shored up its rule over much of the country’s populated west. Now, it is marching eastward towards the Deir al-Zor region near the Iraqi border.

The war, which has killed hundreds of thousands of people, has reached its “penultimate stage” as foreign powers that backed rebels change their policies, Shaaban said in comments to Lebanese al-Mayadeen TV carried on Syrian state news agency SANA on Thursday.

U.S. President Donald Trump has ended CIA support to rebel groups fighting to topple Assad. Turkey, long one of the main rebel backers, has also shifted its priority away from ousting Assad, seeking to mend ties with Russia and curb Kurdish expansion near its border.

“Just as we defeated terrorism, we will fight any illegitimate presence on our land, whether it’s the United States or Turkey,” Shaaban said. “And this is among the challenges we will face at the right time in the right way.”

U.S. forces based in northern Syria are helping Kurdish-led militias push Islamic State militants out of Raqqa city. Washington also has a garrison in the southeast Syrian desert, near a strategic highway border crossing with Iraq, to train local rebels to battle Islamic State.

Shaaban said this week’s Damascus trade fair and regional participation proved a “U-turn was achieved” in the conflict, a shift the Syrian army and allied forces were imposing since they seized Aleppo city late last year.

Still, the multi-sided conflict has raged on along several fronts across the country, with Islamic State losing ground to various separate enemies.

And while the government has forced several major insurgent enclaves to surrender over the past year, rebels still hold swathes of land, including their stronghold of Idlib province and a pocket of territory near Damascus.

The battle against rebels in western Syria has recently shifted down several gears after a string of ceasefire deals, including one Moscow and Washington brokered for the southwest.

With firepower freed up by the truces, the government is extending its grip towards Islamic State territory in the vast eastern deserts.

Syria’s war, which spiraled into violence after mass protests against Assad’s rule in 2011, has made more than 11 million people homeless and sparked a global refugee crisis.