The Syrian government and its most important ally, Russia, announced on Thursday that they had reached a cease-fire agreement with Syrian rebels and with Turkey — a potential turning point in a civil war that has lasted nearly six years and claimed hundreds of thousands of lives.
The announcement follows the retaking of all of Aleppo, once Syria’s industrial capital and a stronghold of the opposition, by forces loyal to President Bashar al-Assad, and negotiations in Moscow that involved Mr. Assad’s government, Russia, Iran and Turkey — but, pointedly, not the United States.
Not included in the agreement is the Islamic State, which controls territory in eastern Syria and across the border with Iraq; the Syrian affiliate of Al Qaeda, which is strongest in the country’s northwest; and “groups linked to them.”
It was not clear which of the scores of rebel groups scattered across Syria had agreed to the cease-fire, nor whether those that had not been consulted would abide by it. Throughout the war, rebel forces have failed to form a united leadership, and infighting among groups has been common.
It was also unclear what criteria the Syrian military and its Russian allies would use to define groups “linked” to the jihadists. In the past, they have dismissed much of the armed opposition as “terrorists” who could not be distinguished from jihadist groups.
Russia, Mr. Assad’s backer, and Turkey, which supports some of the rebels, will guarantee the truce, to begin at midnight on Thursday, President Vladimir V. Putin of Russia said. Minutes later, the Syrian military said it would halt operations nationwide starting at midnight.
The two sides actually signed three agreements, Mr. Putin said: the cease-fire itself; an agreement detailing how it would be carried out; and a third expressing readiness to begin peace talks for a settlement to the conflict.
Mr. Putin said that Mr. Assad’s government and the opposition would take part in peace talks in Kazakhstan, but he did not announce a date.
The Russian defense minister, Sergei K. Shoigu, said the truce would include 62,000 opposition fighters across Syria, and that the Russian military had set up a hotline with its Turkish counterpart to allow immediate communication about the truce and whether it was being met.
In a brief statement, the Syrian Army said the cease-fire came “after the victories and successes that our armed forces accomplished in more than one place,” an allusion to the recent retaking of Aleppo by government forces and allied militias.
The cease-fire agreement appeared to reflect the changed geopolitical reality since Donald J. Trump’s election as president of the United States. Mr. Trump has called President Obama’s Syria policies a failure and has backed the removal of remaining support for Syrian rebels, vowing to make fighting terrorism virtually the entirety of his administration’s Syria policy.
Mr. Assad has called Mr. Trump “a natural ally” in that fight, and the Russian foreign minister, Sergey V. Lavrov, said on Thursday that Mr. Trump’s administration would be welcome to join the peace process after he starts on Jan. 20.
“I would hope that, after the Donald Trump administration takes office, it will also be able to join these efforts,” Mr. Lavrov said at the meeting, shown on state-run television.
In Turkey, the government said that the Lebanese militia Hezbollah — which is backed by Iran and has sent thousands of fighters to battle Mr. Assad’s forces — should withdraw from Syria.
“All foreign fighters need to leave Syria. Hezbollah needs to return to Lebanon,” Turkish foreign minister Mevlut Cavusoglu said.
The foreign minister, Mevlut Cavusoglu, told the Turkish news channel A Haber on Thursday that Turkey would guarantee rebel compliance with the cease-fire agreement, while Russia would guarantee adherence by Mr. Assad’s government. Iran would also help monitor compliance by Mr. Assad’s government and by allied Shiite militias, including Hezbollah, he said.
Demands that troops from Lebanese Shi’ite Hezbollah leave Syria may not sit well with Iran, another major supporter of Assad. Hezbollah troops have been fighting alongside Syrian government forces against rebels opposed to Assad.