TRIPOLI, Libya - Gunmen attacked a security forces headquarters in Libya's eastern city of Benghazi early Friday, killing nine people and wounding 24, authorities said, blaming an Islamic extremist group allegedly behind the attack of a U.S. diplomatic post there.

A security official said the attack started when dozens of gunmen opened fire with machine guns and mortars. The onslaught lasted for an hour.

Libyan commandos later arrived and fought the attackers, though the official said they suffered heavy casualties. A statement issued by the interim government and read by cabinet spokesman Ahmed al-Amin put the death toll at nine people. Milad al-Zowi, a commando spokesman, said the dead were six army commandos and three police officers. Al-Zowe said that three soldiers and a police officer were missing after the battle.

A local hospital official said some of the slain troops were badly butchered, with some corpses burned.

The official said his hospital treated 24 people wounded in the fighting, with most suffering gunshot wounds to the chest and the abdomen. Some were in critical condition, he said.

The government said a number of militants were killed, while others were wounded and arrested. The statement did not elaborate.

Attackers likely tried to get their hands on a car loaded with weapons and ammunition that the security forces had confiscated the previous night, authorities added. A security official at the Benghazi headquarters, Gamal al-Amami, said the driver of the vehicle belonged to the Libya Shield militia.

The hospital official and security official spoke on condition of anonymity.

The government's statement blamed Ansar al-Shariah, a hard-line Islamist militia, for Friday's attack, along with other "criminal groups."