Eight people were killed and up to 15 wounded when suspected Islamist militants tried to storm the Libyan government security headquarters in Benghazi on Friday, army officials and medics said.
The dead were soldiers and police officers, army officials said. Huge explosions could be heard during a firefight in the early morning that lasted more than an hour. Special forces later secured the headquarters, near the city center.
The bodies of two soldiers, kidnapped by militants during the attack, were found later bearing signs of torture, a medical source said.
Libya's central government is struggling to control armed groups, militias and brigades of former rebels who helped oust longtime leader Muammar Gaddafi in 2011 and refuse to disarm.
Special forces have often clashed with Islamist militants in Benghazi, Libya's second-largest city that dominates the volatile eastern region, including from Ansar al-Sharia, listed as a terrorist organization by the United States.
Armed men also attacked the apartment of Benghazi's security chief Colonel Ramadan al-Wahishi. He was not hurt, a security official said.
Car bombings and assassinations of soldiers and police officers have become common in Benghazi, where a suicide bomber detonated an explosives-packed minibus outside a special forces camp on Tuesday, killing two people and wounding two.
Most countries have closed their consulates in the city and some foreign airlines have stopped flying there since the U.S. ambassador and three other Americans were killed in an Islamist militant attack in September 2012.
In December, a suicide bomber killed 13 outside an army camp on the outskirts of Benghazi, in the first suicide attack since the 2011 NATO-backed civil war that toppled Gaddafi.
Western diplomats worry the violence will spill over to the capital Tripoli where the security situation has also worsened. Kidnappings of foreign diplomats have been on the rise as well as nightly shootouts near the airport road.
Western and Arab allies are training Libya's fledgling armed forces but the military is still no match for the heavily armed former rebels and militias who often use the threat of force to make demands on the state.