President Vladimir Putin has ordered the withdrawal of Russian troops from Syria, where Russia has been bombing insurgent groups and supporting the Syrian government for the past five months, Russian state media reported.

In a surprise move, Putin said Monday the removal of the “main part” of Russian military in Syria will begin Tuesday.

“I think that the task given to the ministry of defense has been mainly accomplished,” the Russian president said at a meeting with Russia’s defense and foreign-affairs ministers.

The decision comes as the various factions involved in Syria’s civil war began United Nations-mediated peace talks in Switzerland Monday. Russian state media said Putin’s decision was made in agreement with Syrian President Bashar al-Assad, a longtime ally of Moscow.

Last October, Russia announced an air campaign against targets in Syria it described as terrorist organizations, including the Islamic State and al-Qaeda affiliated groups. Its involvement marked the country’s first military operation outside Europe since the 1980s, when it invaded Afghanistan.

Two days before the first airstrikes, Putin gave a speech at the annual United Nations General Assembly that hinted at Russia’s forthcoming intervention in Syria.

“We think it is an enormous mistake to refuse to cooperate with the Syrian government and its armed forces, who are valiantly fighting terrorism face to face,” he said back then.

The first spate of Russian airstrikes appeared to hit areas where the Islamic State was not present, and were aimed at territory controlled by rebel groups opposed to Assad. The U.S. and Russia, who are on opposing sides regarding the Assad government, traded criticism over who was bombing what. But last month, the two countries, along with European and Arab nations, together brokered a temporary cease-fire among the parties involved in the Syrian civil war. UN officials say the accord has led to a significant reduction in violence, despite some violations.

The Syrian government, backed by Russian airstrikes, has recently made gains in capturing territory held by both rebel groups and Islamic State militants.