Tripoli, Libya (CNN) -- At least nine Libyan soldiers were killed in fighting between government forces and Islamist militants in Benghazi on Friday, officials said.
The fighting began when members of the Islamist armed group Ansar al Sharia and other "criminal groups" attacked the headquarters of the Benghazi security directorate early Friday, the Libyan interim government said in a statement.
Health officials said 19 soldiers and policemen were wounded, and some of the attackers were also killed, wounded or taken captive, according to the government.
Residents and activists reported explosions and intense gunfire that lasted about an hour at dawn before army special forces troops took control of the area. The government said the attackers used small, medium and heavy weapons in their assault.
The government condemned the attack and praised the special forces and other security personnel in Benghazi "for their resilience."
The statement went on to say the government will not "allow the presence of terrorists or armed criminal groups that operate outside the legitimacy of the state, it will not allow states within a state."
Security forces in Benghazi, Libya's second-largest city, have often been targets of assassinations and bomb attacks blamed on Islamist extremist groups.
On Tuesday, at least two soldiers were killed and a number of others were wounded when a car bomb blew up outside an army base in Benghazi.
While no group has claimed responsibility for the violence that has gripped the eastern city, residents and officials have blamed it on groups including Ansar al Sharia, which has clashed with the army in recent months. The United States designated the militant group a terrorist organization this year for its involvement in violence in Benghazi, including the U.S. Consulate attack in 2012.
The security situation in Benghazi has been a major challenge for the Libyan government, with near daily assassinations and kidnappings, which mostly target security forces.
There has been growing concern about the increasing presence and influence of radical militant groups in the North African country after the 2011 revolution that overthrew the Gadhafi regime.
A recently released annual report by the U.S. State Department on global terrorism trends singled out Libya as an area of concern and instability.
"Libya's porous borders, the weakness of Libya's nascent security institutions, and large amounts of loose small arms create opportunities for violent extremists," the report said.
During an official visit to the Libyan capital last week, Deputy Secretary of State William Burns voiced his concerns about the situation and pledged U.S. support to Libya.
"The rising threat of violent extremism, whether it is people using violence for political purposes or the role of terrorist groups, is an enormous challenge first and foremost to the people of Libya, but also to Libya's international partners as well. We recognize the severity of that threat," he told reporters in Tripoli.
"We have all suffered from it, whether it is Americans or Libyans or others around the world, and that is why we have such a sense of urgency, and such a sense of determination, to help Libyans build their own security capacity, to deepen counterterrorism cooperation, and also to promote the kind of healthy political process and economic process that increases the chances for greater security over the long term."