A gun battle between two Libyan rival militias raged around a Tripoli security headquarters building on Sunday, highlighting the precariousness of peace in the capital more than a year after a popular armed revolt ousted Muammar Gadhafi.

At least five people were wounded in the clash, and a bullet pierced into a nearby hospital, causing panic.

Residents in the south Tripoli district of Sidi Khalifa said the fight erupted just after midnight on Sunday when two militia units authorized by the official Supreme Security Committee got into an argument over a detained member of one of the militias.

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

A rocket-propelled grenade (RPG) was fired at the SSC base, damaging the building. The militia based in a post office building returned fire with another RPG.

Gunfire rang through the neighborhood as civilians were forced to block off the al-Zawiya street where the fighting raged, to prevent cars from driving into the battleground. Many civilians went home to get their own private arms.

A bullet shot through the building caused panic at the nearby Tripoli Central Hospital, with doctors and nurses running for cover. Dr. Khaled Ben Nour said five casualties from the fighting 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.

Libya's rulers have struggled to control semi-official armed groups who are competing for power and outgun the police and army in the north African country a year after Gadhafi's fall.