BEIRUT — Thousands of Syrians poured into Lebanon, taking shelter in wedding halls and makeshift shacks after fleeing heavy fighting in a mountainous region across the border in Syria, while a massive explosion Sunday targeting a government building outside Damascus killed at least 31 soldiers.

The clashes in Qalamoun, an area that stretches north of the Syrian capital along the Lebanese frontier, appeared to be part of a long-anticipated government offensive aimed at cutting an important rebel supply route and cementing President Bashar Assad’s hold on a key corridor from the capital to the coast.

A government victory in the strategic region would deal a severe blow to the already beleaguered rebels on Damascus’ doorstep. Over the past month, Assad’s forces have made headway against the rebels on two key fronts, capturing a string of opposition-held suburbs south of Damascus and taking two towns and a military base outside the northern city of Aleppo.

Still, the opposition remains firmly entrenched in other areas around Damascus and capable of carrying out large attacks. A massive bombing Sunday leveled a government office in the northeastern suburb of Harasta, killing at least 31 soldiers, according to the Britain-based Syrian Observatory for Human Rights.

Three brigadiers and one major general were among the dead, according to the group’s director, Rami Abdurrahman. There was no immediate confirmation from government officials or state media.

Since the heavy fighting in Qalamoun began Friday, some 10,000 Syrians have fled across the border to the Lebanese frontier town of Arsal, former Mayor Bassel Hojeiri said. He said the new arrivals have crammed into wedding halls and improvised shacks.

Some families left so quickly that they arrived in Lebanon “without anything except the clothes on their backs,” said Dana Sleiman, who works for the United Nations High Commissioner for Refugees.

She said at least 1,000 Syrian families crossed into Lebanon over the weekend, but many had not yet registered with the U.N., so more precise figures weren’t available.

Sleiman said some of the new arrivals settled into tin shack slums that dot eastern Lebanon’s Bekaa Valley, and they were being offered thick plastic to reinforce their shelters against the cold. The U.N. refugee agency was also distributing blankets, mattresses, food, diapers and hygiene kits to the refugees.