HOMS, Syria — Syria’s government and rebels agreed to a ceasefire Friday in the battleground city of Homs to allow hundreds of fighters holed up in its old quarters to evacuate, a deal that will bring the country’s third-largest city under control of forces loyal to President Bashar Assad.

If the agreement goes through and rebel fighters leave, the capture of the city will be a significant victory for Assad, weeks before presidential elections set for June 3.

Homs, in the central western plains of Syria, was one of the first cities to rise up against his rule three years ago, earning it the nickname of the “capital of the revolution.” After waves of anti-Assad protests by its residents, it was the first city largely taken over by armed rebels as the uprising evolved into outright civil war.

Ever since, Assad’s forces have been engaged in grueling urban warfare trying to wrest it back. For the past months, rebels were isolated and blockaded inside a string of Homs neighborhoods centered around its historic old quarters, battered by heavy government airstrikes and artillery.

An Associated Press team in Homs on Friday said it was unusually quiet, with no shots fired from either side.

“This isn’t what we wanted,” a Homs-based opposition activist, Beibars Tilawi, said of the ceasefire in a Skype interview with The Associated Press. “But it’s all we could get.”

The deal is also a face-saving measure for the rebels. It calls for a 48-hour truce in rebel-held parts of Homs, after which, hundreds of fighters holed up in the area will be evacuated to opposition-held areas north of the city, said Tilawi and another activist who uses the name Thaer Khalildiya, who is based in countryside north of Homs.

News of the ceasefire deal was also reported by the Britain-based Syrian Observatory for Human Rights, which monitors the conflict, and the Al-Manar TV channel, owned by the Lebanese Shiite group Hezbollah, allied to Assad, as well as by Lebanese channel Al-Mayadeen.

There was no immediate comment by Syrian officials.

The 48-hour truce began on Friday, said the Homs-based activists Tilawi and Khalidiya, and the Syrian Observatory. The Observatory bases its information from a network of activists on the ground.

The agreement came weeks after pro-government forces began heavily pounding rebel-held parts of Homs, which were already badly weakened by a blockade that had caused widespread hunger and suffering. Rebels outside Homs did not come to the aid of the fighters within. Despairing, hundreds of fighters at the time surrendered to Assad-loyal forces, activists said.

But a hardcore group remained fighting, dispatching explosive-rigged cars into government controlled areas, killing dozens of people, mostly civilians.

Most recently, a double car bombing on Tuesday killed over 50 people in government-controlled area of Homs.

Also Friday, two suicide bombings in villages of the nearby province of Hama killed 18 people, the state-run television and activists reported.