Two fighters were killed when Libyan militias fought a gun battle across one of Tripoli's busiest streets on Tuesday, in a fresh sign that the new government is struggling to assert control in the post-Gaddafi era.

Tripoli-based former rebels controlling a security compound in the capital fought an hour-long gun battle with at least 24 fighters from Misrata who had come to free a group of prisoners, according to medics and former rebels.

Local residents reported fresh gunfire in Tripoli on Tuesday evening.

More than two months after Libyan leader Muammar Gaddafi was captured and killed, real power still resides with the militias that ousted him. These have carved up the country and capital into competing fiefdoms, each holding out for the share of power they say they are owed.

The battle on Tripoli's Zawiya road was the first between militias since December 11, when soldiers from Libya's new national army and militiamen fought for control of the capital's international airport. Tripoli's city council had set a deadline of December 20 for militias to return to their homes.

The Tripoli militia said they had seized vehicles from the Misrata fighters, while another pickup truck daubed with the words 'The Defence Brigade, Misrata Revolutionaries' was left lying across the highway, riddled with bullets and with blood stains on the back seat.

The Misrata rebels in particular hold a vast arsenal of tanks, rockets and guns that are testing the ability of the government to assert its authority.

(Reporting by Mahmoud Habboush; Editing by Ben Harding)