Heavy gunfire erupted in central Beirut on Sunday after protesters tried to storm the offices of Prime Minister Najib Mikati, demanding that he quit over the assassination of a top intelligence official. 

Witnesses said at least two people had fainted, apparently as a result of tear gas fired by security forces after protesters breached an outer barrier around the prime minister's offices.

Hundreds of protesters, waving flags from the anti-Syrian opposition Future Movement (a mainly Sunni Muslim party) and Christian Lebanese Forces, as well as black Islamist flags, marched on Mikati's offices after the funeral of Wissam Hassan, who was killed by a powerful car bomb in Beirut's Ashrafiyeh district on Friday.

Lebanon's opposition leader Saad Hariri urged supporters to pull back after protesters tried to storm the offices of Prime Minister Najib Mikati, calling for him to quit.

"We want peace, the government should fall but we want that in a peaceful way. I call on all those who are in the streets to pull back," Hariri told supporters through Future Television channel.

Former Prime Minister Fouad al-Siniora, who is from Hariri's party, said "any attempts to storm the Saray (government offices) is unacceptable."

Thousands of people gathered in central Beirut earlier Sunday for the funeral, accusing Syria of involvement in the killing and calling for Najib Mikati to quit.

Heavily armed troops and police stood guard as people flocked to Martyrs' Square in central Beirut.

Many waved the sky-blue flag of the Sunni-based opposition Future Party. Others carried Lebanon's cedar tree national flag but Syrian rebel flags were also seen.

One banner read "Go, go Najib" echoing the slogans of the Arab Spring.

A Sunni Muslim close to the Hariri political clan, he had helped uncover a bomb plot that led to the arrest and indictment in August of a pro-Damascus former Lebanese minister.

He also led an investigation that implicated Syria and its Lebanese ally Hezbollah in the assassination of former prime minister Rafik Hariri in 2005.

Lebanese politicians have accused Syria's leadership of having a role in Hassan's killing, which deepened fears the civil war there is spreading over its borders.

People in the crowd at Martyrs' Square echoed that view.

"We blame Bashar al-Assad, the president of Syria," said Assmaa Diab, 14, from the northern city of Tripoli, Hassan's hometown. She was in the square with her sister and father.

"He is responsible for everything - in the past, now, and if we don't stand up to him, the future," she said.

Diab and other protesters said they wanted Prime Minister Mikati to step down, saying he was too close to Shi'ite Hezbollah, who are part of his government, and to Assad.

"We are here to tell Mikati we don't need him any more and to tell Hezbollah we don't want any more of their games," said Hamza Akhrass, a 22-year-old student who had come from south Lebanon for the funeral. "Mikati takes too much pressure for Syria."

One banner read: "People want the overthrow of Najib."

Mikati said on Saturday he had offered to resign to make way for a government of national unity but he had accepted a request by President Michel Suleiman to stay in office to allow time for talks on a way out of the political crisis.