The Libyan government blamed Islamist militants of the Ansar al-Shariya group for an attack on Friday on the government security forces' headquarters in Benghazi city.
"Armed brigades, including those called Ansar al-Shariya and other criminal groups, attacked with light and heavy weapons the security headquarters in Benghazi," a government statement said.
Earlier, a Libyan security official said militants attacked a security headquarters in the eastern city of Benghazi, killing five soldiers and a policeman.
The official said the attack started when unidentified gunmen opened fire early on Friday and fired mortar shells at the security building for an hour.
Libyan commandos were sent to the scene and engaged the attackers but sustained heavy casualties in the battle.
The official said some of the killed troops were badly butchered and their bodies burned before the attackers fled the scene.
He said 12 troops were also wounded and that three are missing after the battle. The official spoke on condition of anonymity because he was not authorized to speak to media.
Attacks, assassinations and bombings have plagued Benghazi since Moammar Gadhafi's ouster. AP/REUTERS