Rebel fighters fire a heavy machine gun during clashes with Syrian pro-government forces on the front line facing Deir al-Zoghb, a government-held area in northwestern Idlib province, in August. (Omar Haj Kadour/AFP/Getty Images)

Syrian rebels said Saturday they were preparing to withdraw from a besieged town near Syria’s border with Lebanon as part of an unusual U.N.-backed cease-fire involving Iran and Islamist insurgents.

The agreement, reached last week, marks the culmination of weeks of talks held in Turkey to end a brutal siege against rebel-held Zabadani by the Syrian military and Lebanon’s Iranian-backed Hezbollah militia.

Under the deal, rebels linked to the Islamist Ahrar al-Sham group have in turn agreed to halt attacks on the pro-government villages of Foua and Kfarya in the northwestern province of Idlib.

The truce highlights the growing influence wielded over President Bashar al-Assad’s government by Iran, which negotiated the agreement on behalf of the Syrian leader, officials familiar with the exchanges said. The agreement, they said, will be implemented over six months and involves the planned evacuation of rebels and civilians and the release of government-held prisoners.

Analysts said the accord also reflects mounting concern in Iran and Russia — both key Assad allies — about the Syrian leader’s hold on power as insurgents continue to capture territory. Assad now controls less than half of Syria’s territory.

In moves that have alarmed the West, Russia has recently dispatched fighter aircraft and heavy weapons to Syria’s coast in an apparent bid to shore up Assad against rebels and extremist groups such as the Islamic State.

“This cease-fire shows how the Syrian regime is coming under more pressure from its allies to focus on reinforcing the areas that are vital to its survival,” said Imad Salamey, a political science professor at Lebanese American University.

The truce involves a controversial population transfer that, if implemented, will relocate the largely Sunni insurgents and their families from Zabadani to rebel-controlled Idlib province. Turkey, an opponent of Assad, also sponsored the deal.

In return, thousands of the mostly Shiite Muslim inhabitants of Foua and Kfarya will be allowed safe passage to areas under government control. Those villages are the last areas of Idlib province not to have fallen to Ahrar al-Sham and Syria’s al-Qaeda affiliate, Jabhat al-Nusra.

The deal was reached under United Nations observation, rebels said. A spokeswoman for the U.N. envoy to Syria, Staffan de Mistura, could not be reached for comment.

Speaking by telephone, rebels in Zabadani expressed concern that the agreement will allow Syria’s government to re-engineer the country’s demographics. The town has historically been inhabited by Sunnis, the majority in Syria, who lead the rebellion against Assad.

The Syrian government is dominated by Alawites, a minority religious sect that is an offshoot of Shiite Islam. Iran is a Shiite country, and Hezbollah is a Shiite group.

“This an attempt to kick out Sunnis,” said Abu Nidal, the nom de guerre of a fighter who helps run a field hospital in Zabadani. He said government attacks had stopped and that the roughly 700 rebels in Zabadani were preparing to leave the area in the coming days.

Analysts said that removing Sunni insurgents from Zabadani would help Syria’s government further consolidate control over such strategic areas as Damascus, the capital, the border with Lebanon and the western coastline. Those areas are also key to Iran, which funnels weapons to Hezbollah in Lebanon through Zabadani, which was home to about 30,000 people before Syria’s civil war began in 2011.

About 250,000 people have been killed in the Syrian conflict.

“The deal over Zabadani is important to Iran because it wants to secure the border that links Hezbollah and Damascus so that the flow of weapons to Lebanon is not affected,” said Bassam Barabandi, a former Syrian diplomat, who is familiar with the negotiations.

In an interview broadcast Friday, Hezbollah’s leader, Hasan Nasrallah, sought to dismiss the accusations of plans to expel Sunnis. He said that people “who wish to stay in Zabadani are allowed to do so.”

Nasrallah also sought to counter suspicion that Hezbollah has been seriously weakened by the battle over Zabadani. Dozens of the group’s fighters have been killed there, dealing a blow to one of the region’s most powerful militias.

Zabadani, he said in the interview, could have been taken “16 or 17 days” after the group's militants assaulted the town in early July. But Hezbollah restrained itself to ensure the “liberation” of Foua and Kfarya, Nasrallah said.

Since the spring, Hezbollah has been waging an offensive to clear insurgents out of the mountainous border areas between Lebanon and Syria. The insurgents, linked to Ahrar al-Sham and Jabhat al-Nusra, have carried out lethal raids into Lebanon, including attacks against Hezbollah.

More than two years ago, Hezbollah joined forces with Assad’s government to fight the rebellion.