An evacuation of rebel-held districts of Aleppo is back on track and expected to begin within hours, officials on both sides of the war have said.
A rebel retreat from Aleppo would mark a major victory for Syrian President Bashar al-Assad and end years of fighting.
An initial deal that would have seen thousands of civilians and opposition fighters granted safe passage out of the city stalled today and the planned exodus failed to materialise.
Iran, one of Mr Assad's main backers, had imposed new conditions, saying it wanted the simultaneous evacuation of wounded from two villages besieged by rebels, according to rebel and UN sources.
But Abdul Salam Abdul Razak, a military spokesman for the Nour al-Din al Zinki rebel group, said a new agreement had been reached which included those villages in Idlib province.
"Within the coming hours its implementation will begin," he told Reuters.
An official in the Jabha Shamiya rebel group said implementation would begin around 6am (4am Irish time) on Thursday.
An official in the pro-government military alliance confirmed the truce deal was on, and said about 15,000 people would be evacuated from the majority Shia villages, Foua and Kefraya, in return for the evacuation from Aleppo of "militants and their families and whoever wants to leave among civilians".
He said those leaving Aleppo would head for Idlib province to the west of the city.
The Jabha Shamiya official however denied that 15,000 people would leave the two villages and said only the wounded would be evacuated.
It was not immediately clear how the deal had been reached.
We need your consent to load this rte-player contentWe use rte-player to manage extra content that can set cookies on your device and collect data about your activity. Please review their details and accept them to load the content.Manage Preferences
The original ceasefire was brokered by Russia, Mr Assad's most powerful ally, and opposition backer Turkey yesterday.
But the planned evacuation of rebel-held areas did not happen and instead shelling and gunfire erupted in the city today, with Turkey accusing government forces of breaking the truce.
Syrian state television said rebel shelling killed six people.
The UN High Commissioner for Human Rights, Zeid Ra'ad al Hussein, said the bombardment by Syrian government forces and their allies "most likely constitutes war crimes".
Turkish President Tayyip Erdogan and Russian leader Vladimir Putin agreed in a phone call earlier to make a joint effort to start the process, Turkish presidential sources said.
Shortly before the new deal was announced, clashes raged in Aleppo.
At dawn this morning nobody had left under the initial evacuation plan, according to a Reuters witness waiting at the departure point, where 20 buses stood with engines running but showed no sign of moving into rebel districts.
People in eastern Aleppo had packed their bags and burned personal belongings, fearing looting by the Syrian army and its Iranian-backed militia allies.
Officials in the military alliance backing Mr Assad could not be reached for comment on why the evacuation had stalled.
UN war crimes investigators said the Syrian government bore the main responsibility for preventing any attacks and reprisals in eastern Aleppo and that it must hold to account any troops or allied forces committing violations.
In pictures: Evacuation from Syrian city of Aleppo delayed pic.twitter.com/ksKlcmd1MU— RTÉ News (@rtenews) December 14, 2016
In what appeared to be a separate development from the planned evacuation, the Russian defence ministry said 6,000 civilians and 366 fighters had left rebel-held districts over the past 24 hours.
A total of 15,000 people, including 4,000 rebel fighters, wanted to leave Aleppo, according to a media unit run by the Syrian government's ally Hezbollah.
The evacuation plan was the culmination of two weeks of rapid advances by the Syrian army and its allies that drove insurgents back into an ever-smaller pocket of the city under intense air strikes and artillery fire.
By taking full control of Aleppo, Mr Assad has proved the power of his military coalition, aided by Russia's air force and an array of Shia militias from across the region.
Rebels have been supported by the United States, Turkey and Gulf monarchies, but the support they have enjoyed has fallen far short of the direct military backing given to Mr Assad by Russia and Iran.
Russia's decision to deploy its air force to Syria 18 months ago turned the war in Mr Assad's favour after rebel advances across western Syria.
In addition to Aleppo, he has won back insurgent strongholds near the capital, Damascus, this year.