The beginning of the end of the two-year siege of Old Homs came as green buses full of fighters bounced down uneven streets Wednesday — a scene that was captured in a photo that was retweeted hundreds of times.

More than 1,000 rebels were left of those who clung onto five neighborhoods in the central Syrian city while surrounded by forces loyal to President Bashar Assad. Now, after years of violence and weeks of arguing, they are leaving Homs under terms of a conditional surrender.

Local TV footage showed the buses emerging from a shattered landscape of half-collapsed houses and mosques full of bullet holes. They were driven — with their guns — to a rebel-held area north of the city and allowed to go free.

For many who joyfully joined the opposition to Assad in 2011, it was a painful moment. Homs was a wellspring of the uprising, with singing rallies once filling the streets. But gradually the city became a brutal battleground and Assad's forces have firmly reasserted control.

The ceasefire deal came after days of intense negotiations that activists say were conducted in the Safir hotel on the edge of the old city. U.N. Humanitarian Coordinator Yacoub el Hillo was one overseer of the talks. Rebels claim that Iranian officials were also present, though an Iranian diplomat denied this.

According to a monitoring group, the rebels, drawn from many factions, promised to allow aid into two pro-regime neighborhoods — Nabul and Zahra — that they have besieged for months. They agreed to hand over Homs to government troops. Although Assad's soldiers and informal militias have made incursions into the old city in recent weeks, they have been unable to take it by force. The surrounding buildings and streets are heavily mined. Rebels say massive bombings in pro-regime areas last week, which killed more than 100 civilians, were key in pushing the regime to make a deal.

This latest agreement comes after the U.N. brokered a deal in February to allow the evacuation of hundreds of civilians from Homs, and for food and medicine to come in. Residents had resorted to eating grass, cats and dogs. Medicines and clean water were scarce. Several hundred fighters also left in that evacuation, and were detained. Some are still under investigation. Opposition activists say there are around 120 civilians left in the enclave, all of whom are now set to leave.

The surrender also comes as some rebel groups elsewhere in Syria have received a few anti-tank missiles, with the knowledge of the U.S. Videos posted show the groups proudly annihilating regime tanks. But Assad's forces have made significant gains in recent weeks in the crucial suburbs around Damascus. And while fierce fighting continues around Aleppo, a deluge of crude barrel bombs on the opposition-held east of the city has destroyed swaths of that area.

In Homs, ahead of a June 3 presidential election that Assad will surely win, posters of him have appeared in what were opposition strongholds. Some rebels have vowed to keep fighting, but the significance of exiting their bastion is clear. A few days ago, one activist in Homs posted a picture on Facebook of graffiti scrawled on a street littered with bullet casings. It reads: "and when I leave, be sure I did everything I could to stay."