Hundreds of rebel fighters and thousands of civilians are to evacuate the besieged Damascus suburb of Daraya after rebels and the Syrian army agreed to a deal, a rebel leader and a state news agency have said.

Thursday's development ended one of the longest standoffs in the Syria's five-year war.

"Seven hundred armed men with their personal weapons will leave Daraya to head to the [rebel-controlled] city of Idlib, while thousands of men and women with their families will be taken to reception centres," Syrian state news agency SANA reported.

One rebel official in the suburb told AFP news agency that the civilians would be transferred to regions around Damascus under government control.

The rebels would have to surrender other armaments to the army.

A military source told AFP that the army would enter Daraya after the evacuation of the rebel-held town.

"We reached agreement on the evacuation of all of the people of Daraya, civilians and fighters," said Captain Abu Jamal, head of Liwa Shuhada al-Islam, the largest of two main rebel groups inside Daraya.

The evacuation, which is similar to deals concluded in several besieged areas throughout the course of the conflict, could start as early as Friday and last for two or three days, he said.

READ MORE: Syrian Civil War Map

"It's difficult to describe my feelings, we kept holding on for four years to the last breath. The city was destroyed over our heads and we are now not leaving a city but a pile of rubble," said Hamam al Sukri, a resident who had been living in a basement with his six-member family, told Reuters news agency.

In 2012, several hundred people were killed in Daraya, including civilians, many execution style, after security forces stormed the suburb after locals took up arms. Both the army and rebels blamed the other.

Rebels and local council sources said around 5,000 people would be evacuated from the suburb that, before the war, was home to a quarter of a million people.

This would include around 1,000 fighters who would be evacuated with their light weapons to rebel-held areas in northern Syria. The army would reassert its control over the city and seize heavy weapons, state media said.

Abu Jamal said the deal was reached after a ceasefire on Wednesday was followed by talks that led to the authorities agreeing to rebel terms for an evacuation.

"We got the freedom of getting civilians to leave freely to liberated areas or wherever they want. Otherwise it would have been a final surrender with the regime taking us as prisoners of war and sending civilians to an unknown fate," Abu Jamal, the rebel commander, said.

The Syrian army has surrounded rebels and civilians and blocked food deliveries in Daraya since 2012, regularly bombing the area only 7km from President Bashar al-Assad's seat of power.

Authorities agreed in June of this year to allow food deliveries into the suburb under a ceasefire deal, but only one shipment has been made since then.

In the past few weeks the army has escalated its bombardment of the rebel-held bastion, intensifying the use of barrel and incendiary bombs. Last week Daraya's only remaining hospital was hit, rebels and aid workers said.