Five people injured as rival militia groups clash for hours outside a state security building in Tripoli.

Rival Libyan militias fired guns and rocket-propelled grenades at each other in Tripoli on Sunday and set fire to a former intelligence building, one of the worst breakdowns in security in the capital since Muammar Gaddafi’s fall.

At least five people were wounded and a stray bullet entered a hospital in the heart of the city, where residents rushed to arm themselves, saying calls to police had gone unheeded. After more than 12 hours, the army moved in to restore order.

The violence underscored the challenge faced by Libya’s new government in reining in militias that gained power during the conflict that ended Gaddafi’s 42-year rule a year ago and holding together a country riven with clan, regional and sectarian divisions.

The heaviest fighting took place in the early morning, a witness told the AFP news agency. By early afternoon, a building belonging to the Supreme Security Committee (SSC), a body set up last year to try to regulate armed groups, was in flames and being looted by members of a rival militia faction, witnesses said.

A sports shop that helps fund one of the militia groups was also looted.

Both militias are affiliated to the SSC, an umbrella group for various armed groups that refused to join the official police or army, saying they were still run by Gaddafi loyalists.

Civilians blocked the street where the fighting raged to prevent cars entering the battleground where the sound of gunfire rang out. Many civilians went home to get their own arms.

“We called the police early in the morning to help us stop the shooting, but no one came,” resident Khaled Mohamed told Reuters.

A stray bullet caused panic at the nearby Tripoli Central Hospital, sending doctors and nurses running for cover. Doctor Khaled Ben Nour said five casualties had been brought in.

“We have real patients with real needs. These rogue militias need to leave us in peace so we can do our jobs,” Ben Nour said.

‘Lawless group of men’

Some fighters said the clash was over the detention of the militia member while others said the SSC headquarters – a former intelligence building – had been occupied by a militia called Support Unit No. 8, led by Mohamed al-Warfali.

A group of rival militias – also belonging to the SCC – fired at the building from a former post office.

“Mohamed al-Warfali and his lawless group of men have occupied the SSC building and refuse to come out,” said militia member Mohamed al-Himrazy who accused Warfali’s group of breaking SSC rules.

Others said that a militia group came to free a member detained by Warfali in the SSC building.

The confusion over the reason for the attack underscored the dangerously chaotic nature of the semi-official militias in Libya, which hold a great deal of power and have loyalties that do not necessarily match the government’s.

A force of about 200 soldiers from Libya’s national army eventually moved into the SSC building occupied by Warfali’s militia and succeeded in taking over control.

The SSC, run and paid for by the Interior Ministry, is much better armed that the official police. The ministry has repeatedly promised to disarm the militias but has yet to do so, to the disgust of many Libyans.

“The government needs to find a solution for this security mess,” said resident Khaled Ahmed.

“It’s been two years since the revolution and there is still no security. They either need to find a solution or we take to the streets again.”

Benghazi blast

On Sunday, violence also erupted outside the capital.

A car bomb exploded in front of a police station in Benghazi, injuring three police officers in the latest in a series of attacks on security officials in Libya’s second largest city, where the U.S. ambassador was killed in September.

The front of the central Hadayeq police station was charred and blackened with smoke. The entrance to the station was completely damaged, with glass strewn on the street and firefighters putting out a damaged police car that was on fire.

A Reuters photographer saw three policemen receive first aid for minor injuries in front of the station. Officials at the scene said there were no deaths.