The chaotic scene in Lebanon's capital came in the midst of a funeral for a top intelligence official who was killed in a car bombing that many blame on the regime in neighbouring Syria.
Several hundred protesters made it to within 50 metres of the entrance of Lebanon's government palace, with thousands more behind them.
The gunfire appeared to push the crowd back. Army commandos marched into the streets wielding clubs. The crowd had marched from Martrys Square, where thousands of people had turned out for Brig.-Gen. Wissam al-Hassan's funeral.
As the battle raged, with protesters and security personnel pelting each other with hunks of concrete, metal bars and tear gas canisters, former Prime Minister Fuad Saniora appealed for calm.
"The use of violence is unacceptable and does not represent the image that we want," Saniora said in a televised address.
A powerful car bomb in Beirut on Friday wounded dozens of people and killed eight others, including al-Hassan, a Sunni Muslim who was close to the political clan of assassinated former prime minister Rafik Hariri.
His death has inflamed Sunni anger in Lebanon.
Anger at Syria's influence
The protesters believe the government is too close to Syria and Damascus' ally in Lebanon, the Shia group Hezbollah.
Many Lebanese have raised the possibility that the latest bombing in Beirut is connected to the civil war in neighbouring Syria, which has sent destabilizing ripples through Lebanon for the past 19 months.
Al-Hassan led an investigation over the summer that implicated a pro-Syrian Lebanese politician and one of the highest aides to Syrian President Bashar al-Assad in plots to carry out bombings in Lebanon.
Former information minister Michel Samaha was arrested in August in an overnight raid on his home in Khenchara, Lebanon.
Even before Friday's bombing, the civil war in Syria had set off violence in Lebanon and deepened tensions between supporters and opponents of Assad's regime. The assassination has laid bare how vulnerable Lebanon is to renewed strife, threatening to shatter a fragile political balance struck after decades of civil strife — much of it linked to Syria.Many of Lebanon's Sunni Muslims have backed Syria's mainly Sunni rebels, while Shia Muslims have tended to back Assad.
Security was extra tight for al-Hassan's funeral in the Lebanese capital, where thousands of people were gathering in the central Martyrs' Square.
Al-Hassan's body was to be buried next to the tomb of Hariri, who died in a 2005 truck bombing in Beirut.
Lebanese security forces set up road blocks and cordoned off the square ahead of the public funeral. Armoured vehicles and troop transports patrolled nearby streets.
Large posters erected in Lebanon describe al-Hassan, 47, as a "martyr of sovereignty and independence" and "the martyr of Lebanon's dignity."
In central Beirut, dozens of anti-Syrian protesters set up tents near the cabinet headquarters, saying they will stay until Prime Minister Najib Mikati's government, which is dominated by the Shia militant group Hezbollah and its allies, resigns.
Hezbollah is Syria's most powerful ally in Lebanon, which for much of the past 30 years has lived under Syrian military and political domination.Suggest a correction