BEIRUT (Reuters) - Two pro-government villages in northwestern Syria were evacuated on Thursday, state television said, in an agreement between the Damascus government and insurgents who had laid siege to them for several years.

In exchange, the government was due to release hundreds of prisoners from its jails. Pro-Damascus TV stations said at least 20 buses carrying “militants” released from jail had crossed into rebel-held territory under the agreement.

Close to 7,000 people - civilians and fighters - were due to leave the loyalist Shi’ite villages of al-Foua and Kefraya in Idlib province. They were ferried out in a convoy of buses through rebel-held territory to nearby government-held territory in Aleppo province, state TV footage showed.

A commander in the regional alliance that backs Damascus said insurgents in Idlib were still holding around 1,000 of the evacuees near the crossing on Thursday night.

Footage broadcast by al-Manar TV, which is run by the pro-Damascus Lebanese Shi’ite group Hezbollah, showed buses arriving at a government checkpoint in al-Eis, east of the two villages, earlier in the day. Many had smashed windscreens - Al-Manar’s reporter said they had been pelted with rocks as they drove through rebel areas.

A separate convoy of buses was shown crossing from al-Eis into rebel-held territory. Al-Manar’s reporter at the scene said they were carrying detainees released under the deal.

Population transfers have been a common feature of the seven-year war, mostly at the expense of Assad’s opponents.

Rebels and civilians have been bussed out of their home towns to insurgent territory in the north as government troops advanced, backed by Russian and Iranian forces. The opposition has decried this as a systematic policy of forced displacement, or “demographic change”, to get rid of Assad’s opponents.

Assad has vowed to recover the entire country, and Idlib province is the last major insurgent-held part of Syria. The Syrian army and its allies are now waging a rapidly advancing campaign against rebels in the southwest, the other major area where Assad’s enemies were holding out.

Slideshow ( 12 images )

The conflict, which has killed half a million Syrians and driven 11 million from their homes, has long had a sectarian dimension. Assad is from the Alawite sect, an offshoot of Shi’ite Islam, while most Syrians are Sunni Muslims.

Shi’ite militias backed by Iran have deployed from across the region to help Damascus against the mainly Sunni rebels.

More than 120 buses arrived at the Shi’ite villages on Wednesday to take out the residents and fighters. Ambulances left first, ferrying out the sick to a government checkpoint. State-run al-Ikhbariya TV said 10 ambulances carrying a number of people in critical condition left the villages.

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

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

The evacuees were due to include Alawites taken hostage by rebels when they overran Idlib more than three years ago, the commander said.