An evacuation began overnight of thousands of people from two loyalist Syrian villages that are besieged by rebels in the northwest, a war monitor said, with the government expected to release hundreds of detainees in return, Reuters reports.

The Shi’ite villages of al-Foua and Kefraya are expected to be emptied of all their residents and fighters. More than 100 buses arrived to transport residents and fighters from the villages to nearby government-held territory in Aleppo province.

The evacuation began with ambulances ferrying out the sick, the Syrian Observatory for Human Rights war monitor reported.

Syrian state-run al-Ikhbariya TV said 10 ambulances carrying a number of people in critical condition had arrived at a government checkpoint in al-Eis. Al-Manar TV, run by the pro-Damascus Lebanese Shi’ite group Hezbollah, said this completed the first phase of the agreement, and that the upcoming departure of 121 buses in a convoy would complete a second phase.

The villages have been under siege for years by Sunni Islamist rebels in Idlib province, the last major insurgent-held part of Syria. President Bashar al-Assad, who is advancing against rebels in the southwest, has vowed to recover the entire country.

Some 7,000 people are due to leave both villages.

Read: Syrian army pounds southern city of Nawa, reports of casualties

Population transfers have been a common feature of the seven-year Syrian war, mostly at the expense of Assad’s opponents. The conflict has killed an estimated half a million people and driven some 11 million from their homes.

Rebels and civilians have been bussed out of their hometowns to insurgent territory in the north, as government forces advanced with critical help from Russia and Iran.

The opposition has decried it as a systematic policy of forcible displacement against those opposed to Assad, who comes from the Alawite sect, an offshoot of Shi’ite Islam.

The conflict took on a sectarian dimension as it swelled out of protests against Assad’s rule in 2011. Shi’ite Islamist militias backed by Iran have deployed from across the region to help Damascus against rebels, many of whom identified themselves as Sunni Islamists.

Opposition sources said officials from Hayat Tahrir al-Sham, a coalition spearheaded by Syria’s former al-Qaeda offshoot, and Iran’s Revolutionary Guards had negotiated the latest swap.

A commander in the regional alliance that backs Assad and an Islamist rebel source familiar with the secret talks said separately that Turkey was also involved in the process, which builds on a deal from last year that had not been fully implemented.

Read: Regime shelling kills 3 children in Syria’s Hama

State TV said 121 buses had entered al-Foua and Kefraya in Idlib province so far on Wednesday, along with Syrian Arab Red Crescent (SARC) ambulances for sick residents.

The evacuees will include Alawite hostages that rebel factions took when they overran Idlib more than three years ago, it said.

In April last year, thousands of people were shuttled out of the two villages to government territory in a similar mediated agreement.

In exchange, hundreds of residents left two towns at the border with Lebanon, Madaya and Zabadani, which were in the hands of Sunni rebels at the time and under siege from pro-government forces. They were moved to Idlib.

But other parts of the deal – evacuating the people remaining in al-Foua and Kefraya and releasing 1,500 detainees from state prisons – did not go through at the time.