Syria's government has agreed a nationwide ceasefire with rebels in a deal brokered by key ally Russia and opposition-backing Turkey.

The truce, due to begin at midnight, is designed to pave the way for a political solution to the conflict after nearly six years of war.

Russia's President Vladimir Putin said it would be followed by peace talks in Kazakhstan between President Bashar al Assad's government and the opposition.

But one rebel group said the truce excludes Islamic State and the Kurdish YPG militia, while there were conflicting reports about whether it also excludes another group formerly known as the Nusra Front.

Mr Putin acknowledged that agreements were "fragile" and would need "special attention and involvement".

According to RT.com, Putin told a meeting of Russian defence ministers that "This agreement we’ve reached is very fragile, as we all understand. They require special attention and patience, professional attitude, and constant contact with our partners."

Russia said the truce would include 62,000 opposition fighters and that it had set up a hotline with Turkey to monitor compliance.

Mr Putin also said Russia would scale back its presence in the country, where it has provided crucial support to the government, though he did not specify how many troops or weapons would be withdrawn.

Syrian state news agency SANA said the military "declares a comprehensive nationwide cessation of hostilities as of midnight".

It said this followed "successes achieved by the armed forces" - an apparent reference to the capture of rebel-held neighbourhoods in Aleppo earlier this month.

A spokesman for Syria's opposition National Coalition said it backed the ceasefire and "urges all parties to abide by it".

Turkey's foreign ministry said in a statement: "With this agreement, parties have agreed to cease all armed attacks, including aerial, and have promised not to expand the areas they control against each other."

Several previous attempts to bring an end to the civil war - in which more than 300,000 people have been killed - have failed.

Two other nationwide truces, in February and September, were brokered by Russia and the US.

Turkey and Russia oversaw a ceasefire in Aleppo earlier this month that allowed remaining rebels and civilians to flee.

There were signs after the latest deal that their cooperation had for the first time gone beyond peace talks, with reports that Russian war planes had supported a Turkish offensive against Islamic State in northern Syria.