BEIRUT, Dec 30 (Reuters) - A nationwide ceasefire in Syria, brokered by Russia and Turkey which back opposing sides in the conflict, appeared to hold early on Friday after a shaky start during the night in the latest attempt to end nearly six years of bloodshed.

Russian President Vladimir Putin, a key ally of Syrian President Bashar al-Assad, announced the ceasefire on Thursday after forging the agreement with Turkey, a longtime backer of the opposition.

Monitors and a rebel official reported clashes almost immediately after the truce took force at midnight (2200 GMT Thursday) between insurgents and government forces along the provincial boundary between Idlib and Hama, and isolated incidents of gunfire further south. Hours later calm prevailed in areas included in the deal, they said.

Russian Foreign Minister Sergei Lavrov said the United States could join the peace process once President-elect Donald Trump takes office on Jan. 20. He also wanted Egypt to join, together with Saudi Arabia, Qatar, Iraq, Jordan and the United Nations.

A number of rebel groups have signed the agreement, Russia’s Defence Ministry said. Several rebel officials acknowledged the deal, and a spokesman for the Free Syrian Army (FSA), a loose alliance of insurgent groups, said it would abide by the truce.

One FSA commander was optimistic about the truce deal, the third serious attempt at a nationwide ceasefire this year.

“This time I have confidence in its seriousness. There is new international input,” Colonel Fares al-Bayoush said without elaborating.

Syria’s civil war, which began when a peaceful uprising descended into violence in 2011, has resulted in more than 300,000 deaths and displaced more than 11 million people, half its pre-war population.

The ceasefire, in the waning days of U.S. President Barack Obama’s administration, was the first major international diplomatic initiative in the Middle East in decades not to involve the United States.

Syria truce largely holding despite pockets of violence https://t.co/mhy5EIV09k pic.twitter.com/dz8WJih6tE — Al Jazeera News (@AJENews) December 30, 2016

PREVIOUS COLLAPSES

The previous two Syria ceasefires, brokered by Cold War foes Washington and Moscow, took effect in February and September but both collapsed within weeks as warring sides accused each other of truce violations and fighting intensified.

Putin said the parties were also prepared to start peace talks intended to take place in Astana, the capital of Kazakhstan. Syrian state media said late on Thursday those talks would take place “soon.”

The Syrian government will be negotiating from a strong position after its army and their allies, including Shi’ite militias supported by Iran, along with Russian air power, routed rebels in their last major urban stronghold of Aleppo this month.

Moscow’s air campaign since September last year has turned the civil war in Assad’s favor, and the last rebels left Aleppo for areas that are still under rebel control to the west of the city, including the province of Idlib.

The ceasefire will have to hold before talks can take place.

In a sign that the latest truce could be as challenging to maintain as its predecessors, there was confusion over which rebel groups would be covered by the ceasefire.

The Syrian army said the agreement did not include the radical Islamist group Islamic State, fighters affiliated to al Qaeda’s former branch the Nusra Front, or any factions linked to those jihadist groups.

But several rebel officials said the agreement did include the former Nusra Front - now known as Jabhat Fateh al-Sham - which announced in July that it was severing ties with al Qaeda.

The powerful Islamist insurgent group Ahrar al-Sham said it had not signed the ceasefire agreement because of “reservations,” which it would make clear in due course.

Maxim Shemetov / Reuters Russian Foreign Minister Sergei Lavrov, left, and his Turkish counterpart Mevlut Cavusoglu. The previous two Syria ceasefires took effect in February and September, but both collapsed within weeks.

RUSSIA-TURKEY DETENTE

The deal also follows a thaw in ties between Russia and Turkey.

Talks on the latest truce picked up momentum after Russia, Iran and Turkey said last week they were ready to back a peace deal and adopted a declaration setting out principles for an agreement.

In a sign of the detente, the Turkish armed forces said on Friday Russian aircraft had carried out three air strikes against Islamic State in the area of al-Bab in northern Syria, killing 12 of the jihadists.

Ankara is backing rebels fighting against Islamic State, which has made enemies of all other sides involved in the conflict.

Putin said opposition groups and the Syrian government had signed a number of documents, including the ceasefire, measures to monitor the truce, and a statement on readiness to start peace talks.

While Ankara has been a big sponsor of the rebellion, Assad’s removal has become a secondary concern to fighting the expansion of Kurdish influence in northern Syria. The chances of Assad’s opponents forcing him from power now seem more remote than at any point in the war.

The United States has been sidelined in recent negotiations and is not due to attend the next round of peace talks in Kazakhstan, a key Russian ally.

Its exclusion reflects growing frustration from both Turkey and Russia over Washington’s policy on Syria, officials have said.

Washington said the news of a ceasefire was positive.

“We hope it will be implemented fully and respected by all parties,” U.S. State Department spokesman Mark Toner said.

James Dobbins, a former senior U.S. diplomat, said the lack of American involvement in the talks between Russia, Iran and Turkey did not preclude the United States from being a major player in the region.

In this case, it was frozen out because Obama leaves office in less than a month and because Turkey and Russia are at odds with the United States over its Syria policy and other issues, said Dobbins, a fellow at RAND, a research organization.

Trump has said he would cooperate more closely with Russia to fight terrorism but it was unclear what that policy would look like, given resistance from the Pentagon and the U.S. intelligence community to closer cooperation with Russia on Syria.