Heavy fighting has erupted around Tripoli International Airport, where rival militias have been battling for control, killing at least four people and forcing thousands from their homes.

The airport standoff is the most serious violence in Tripoli since the 2011 fall of Colonel Gaddafi, with Libya's fragile government unable to assert authority over rival brigades of former rebels fighting for power.

Militias used heavy anti-aircraft cannons, Grad missiles and rockets in exchanges around the Qasr Ben Ghashir neighbourhood, trapping some families while several thousand others fled the fighting, community leaders said.

One witness said gunmen were set up on roofs of homes facing each other, with residents caught in between. "The shells are landing on us from all warring militias," said Mohammed Abdulrahman, a spokesman for the district. "We couldn't reach some families until now."

A doctor from a local hospital said it had received nine wounded from the area.

The fighting broke out just days after one powerful militia said it was ready to put an end to heavy clashes that had deepened fears the vast North African country is becoming a failed state.