* Brigadier General Wissam al-Hassan killed by car bomb on Friday
* Lebanese politicians have accused Syria of role in killing
* Crowd tries to storm prime minister's office
BEIRUT, Oct 21 (Reuters) - The state funeral in Beirut of an assassinated Lebanese intelligence chief ended in violence on Sunday as angry mourners broke away and tried to storm the offices of Prime Minister Najib Mikati, prompting security forces to shoot in the air and fire tear gas to repulse them.
The clashes fed into a growing political crisis in Lebanon linked to the civil war in neighbouring Syria.
Opposition leaders and their supporters accuse Syria of being behind the car bombing that killed Brigadier General Wissam al-Hassan on Friday and say Mikati is too close to Syrian President Bashar al-Assad and his Lebanese ally Hezbollah, which is part of Mikati's government.
Thousands turned out in downtown Beirut's Martyrs' Square for Hassan's funeral, which also served as a political rally. The violence erupted after an opposition leader demanded that Mikati step down to pave the way for talks on the crisis.
A group marched to the prime minister's office, then overturned barriers, pulled apart barbed wire coils and threw stones, steel rods and bottle at soldiers and police.
Security forces responded by shooting into air and firing teargas, forcing the protesters to scatter. There were no immediate reports of casualties but the violence was nonetheless shocking to Lebanese who fear the Syrian conflict will spread to their country.
Opposition leader Saad al-Hariri urged supporters to refrain from any more violence.
"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 after the attack, speaking on the Future Television channel.
However as night fell groups of youths blocked the road to the international airport with piles of burning tyres. The highway south to Sidon was also cut.
Sunni gunmen in Beirut's southern suburbs set up checkpoints and were inspecting identification papers - an ominous reminder of the civil war days.
Gunmen were also patrolling the streets of the northern city of Tripoli, scene of previous clashes between Sunnis and Alawites sympathetic to different sides in the Syria war.
Sunday's events highlighted how the 19-month-old uprising against Assad in Syria has exacerbated deep-seated sectarian tensions in Lebanon, which is still scarred from its 1975-90 civil war.
Sunni-led rebels are fighting to overthrow Assad, who is from the Alawite minority, which has its roots in Shi'ite Islam. Lebanon's religious communities are divided between those that support Assad and those that back the rebels.
A HERO'S FUNERAL
Hassan, 47, was a Sunni Muslim and senior intelligence official who had helped uncover a bomb plot that led to the arrest and indictment in August of a pro-Assad former Lebanese minister.
He also led an investigation that implicated Syria and the Shi'ite Hezbollah in the assassination of Lebanon's former prime minister Rafik al-Hariri in 2005.
Damascus and Hezbollah have condemned Hassan's killing.
But mourners at Martyrs' Square accused Syria of involvement and called for Mikati to quit. One banner read "Go, go Najib" echoing the slogans of the Arab Spring.
The violence broke out after Fouad al-Siniora, a former prime minister, said the opposition rejected any dialogue to overcome the political crisis caused by Hassan's killing unless the government first resigned.
"No talks before the government leaves, no dialogue over the blood of our martyrs," Siniora said to roars of approval from the crowd.
At the start of the funeral, senior politicians and the military and security top brass turned out at the Internal Security Force headquarters for a ceremony held with full military honours and broadcast live on national television.
Hassan's wife and two sons, the youngest weeping, listened as he was eulogised by the head of police, Ashraf Rifi, and President Michel Suleiman.
Suleiman said the government and people must work "shoulder to shoulder" to overcome the challenges posed by the killing.
"I tell the judiciary do not hesitate, the people are with you, and I tell the security be firm, the people are with you, with you. And I tell the politicians and the government do not provide cover to the perpetrator."
In keeping with custom for state funerals, church bells pealed as police officers carried the flag-draped coffins of Hassan and his bodyguard to the mosque on Martyrs' Square through chanting crowds. Moslem prayers were broadcast by loudspeaker from the mosque.
"We blame Bashar al-Assad, the president of Syria," said Assmaa Diab, 14, from the northern Lebanese city of Tripoli, Hassan's home town. 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.
The prime minister was also a focus of their anger.
"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 from south Lebanon.
"Mikati takes too much pressure for Syria."
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.
Mikati sought in vain to insulate the country from turmoil in its larger neighbour, which has long played a role in Lebanese politics. He himself said he suspected Hassan's assassination was linked to his role in uncovering Syrian involvement in the August bomb plot.