Rooftop snipers and knife-wielding assailants killed six soldiers in Libya's eastern city of Benghazi early Saturday, officials said, in the largest attack on the country's new security forces to date.

The brazen overnight assault by hundreds of plain-clothed gunmen on security installations forced soldiers to withdraw from some of their bases. In one case, soldiers fled out the back door of the First Infantry Brigade's headquarters in Benghazi as assailants stormed the main gate, torching the building and two military vehicles.

Security officials say 11 people were wounded. The figure includes assailants as well.

It was the second deadly incident to strike the city this week. Thirty-one people, mostly civilians, were killed days earlier at an anti-militia protest.

The latest violence underscored the government's failure to clamp down on a proliferation of weapons after the country's eight month civil war ousted longtime dictator Moammar Gadhafi in late 2011. It also comes as the government is trying to rebuild its security forces and reign in militias, many of which were born out of rebel groups that fought Gadhafi's forces.

Benghazi, the country's second largest city and the first to revolt against Gadhafi, has been rocked over the past year by multiple assassinations of police officials and attacks on foreign missions including the U.S. consulate last September that killed Ambassador Chris Stevens and three other Americans.

Tensions have been boiling in the city over militias ever since, with the military taking over several of their bases this week. The country's nascent army and police force still rely on militias to help maintain security, putting many on the government's payroll. Many of these militias, though, are reluctant to come under the full authority of the government and say former regime officials must first be fired.

As with past attacks, no group claimed responsibility Saturday. The Defense Ministry says it is investigating, and no arrests have been announced.

A spokesman for Benghazi's Joint Operations Security Room, Mohammed Hejazi, was quoted by Libya's official news agency LANA as saying that all six of the soldiers killed were from an elite military unit known as Saaqa. He said four died from gunshots to the head from snipers and two were "slaughtered by knives," but gave no other details.

Saaqa confirmed the six killed were from its ranks. On its Facebook page, it blamed Islamic extremists for the attacks.

"They sacrificed with their lives to defend with honor, full force, valor and the legitimacy of the state," the statement by Saaqa added. It posted photos of the deceased and their names.

The attacks started just after midnight when attackers opened fire with automatic rifles on the infantry brigade headquarters and threw explosives on its roof.

Assailants then attempted to overrun Saaqa's base in the neighborhood of el-Leithy. Security officials said this is when the six were killed.

A video posted on YouTube showed a gunman standing on the roof of an apartment building in el-Leithy exchanging fire with a man in the back of a pick-up truck manning a mounted machine gun. The video corresponded to reporting by The Associated Press.

Asmaa Hawaz, a resident of el-Leithy, told the AP she heard explosions and gunfire for several hours until dawn, and that now the situation is quiet.

She said men in civilian clothes carrying Kalashnikov rifles and rocket-propelled grenades were patrolling the area by late morning, and suggested they could be area residents who joined Saaqa to fight the other gunmen.

The fighting also broke out along the city's airport road, which officials closed Saturday out of concerns for security. Troop reinforcements have been sent from the capital Tripoli to Benghazi.

The First Infantry Brigade headquarters that was burned falls under the authority of the new interim chief of staff Salem Qineydi, who vowed just days ago that militiamen would have to lay down their arms or join the army by year's end.

He warned on state TV overnight of a "bloodbath" if the army continues to be attacked. Qineydi toned down his rhetoric later in the day when he spoke to Libya al-Ahrar TV, saying he was open to holding dialogue with the assailants to hear their demands.

"If their demands are reasonable, we are ready. But if their demands are to occupy areas, then this has ended," he said, pointing to the anti-militia protest in which people demanded an end to the armed groups.

"In the end this is Libya and we are all Libyans. The blood of Libyans is precious. We do not have to have bloodshed at every turn," he said, reiterating that the army is open for former rebels to join.

At least five other security posts were attacked throughout the night, including a military administration office, a Libyan border guard outpost, the National Security Directorate, other buildings belonging to the First Brigade, and a militia base belonging to pro-federalists in the east. The office of the national oil company, recently moved to Benghazi from the capital Tripoli to appease those calling for more rights for eastern Libya, was also targeted.

The attack on the pro-federalist militia base and the state-run oil company's new office comes after leaders in the east made a renewed push for self-rule this month, including the creation of a separate force to defend the region and collect weapons. Residents in Benghazi have complained for decades about discrimination by the west, where Tripoli is located.

Among those opposed to federalist demands are Islamists, including the head of the government-aligned militia that was involved in the clashes that killed 31 earlier this week. Wassim Bin Hamid had accused federalists of attacking his group's Benghazi headquarters, which was taken over by Saaqa after the violence.

Others say that protesters, many armed, were simply fed up with the militia unit, which was accused of acting with impunity and using the threat of violence to pressure parliament to pass a law banning Gadhafi-era officials from senior government positions for 10 years. Federalists in the east had criticized the militia siege of government buildings leading up to parliament's vote on the law, which may unseat people who once served in Gadhafi's regime even if they defected years ago.