Syrian government forces raised a flag in the city of Homs as hundreds of exhausted Syrian rebels withdrew from their last remaining strongholds in the besieged city. The Free Syrian Army agreed to surrender to President Bashar Assad a bloodstained city that was once the centre of the revolt against him.

For Assad, it is a powerful victory ahead of presidential elections. For the rebels, the sad exit after two years of gruelling assaults and siege captures their sense of abandonment. "We ate grass and leaves until there was nothing left for us to eat," said opposition activist Abu Yassin al-Homsi. "We kept urging the international community to lift the siege but there was no response."

Photos show the scale of the destruction inflicted on Homs from months of bombardment. Buildings are shattered, streets are littered with burnt-out cars.

The city quickly came under a series of crushing government offensives, turning it into a battleground that left entire blocks and much of its historic quarters in ruins. Thousands of people were killed and almost all its residents fled.

Rebels were slowly pushed back. For well over a year, government forces have been besieging rebels in around a dozen districts around its ancient bazaars. With food and medicine short, a first major group — around 1,400 people, including fighters and residents — evacuated earlier this year in a UN-mediated operation.

The last die-hards, including many from the al-Qaida-linked Nusra Front and other Islamic factions, held out for weeks. But they agreed to the cease-fire deal, which includes the release of captives held by rebels in Aleppo and Latakia provinces, and the easing of a rebel siege on two pro-government Shi'ite towns in Aleppo province in return for the safe passage out of Homs.

The evacuation caps a series of successes for Assad's forces. Backed by fighters from the Lebanese Shi'ite militant group Hezbollah, pro-government troops recently seized key territory in rugged mountains near the border with Lebanon and around the capital Damascus.

The government has control of almost all cities, as well as the recently-won Qalamoun region stretching north of Damascus to the Lebanese border and toward Homs. It also has a nearly unquestioned grip on the mountainous Mediterranean coastal region, the heartland of Assad's Alawite minority.

Still, Assad has lost huge territory to the opposition. Rebels hold the northern Aleppo province, much of neighboring Idlib province and the territory along the Turkish border, as well as the Raqqa region in the east — and Aleppo city, the country's largest city and former commercial hub, is carved up into rebel-held and government-held halves. Much of the rural areas in the south are highly contested, and rebels hold a number of surburbs ringing Damascus.