Four people have been killed when rival militias in an area south-west of the Libyan capital exchanged heavy gunfire.

The conflict, rooted in an old tribal rivalry, is one of the hundreds of faultlines running through Libyan society that have left the new rulers struggling to hold the country together since the overthrow of former leader Muammar Gaddafi.

The fighting was between members of the El-Mashasha tribe, based around the town, and fighters from the larger town of Zintan in the mountains to the north.

Shots, including from machine guns, could be heard and all men and boys in Wamis were carrying Kalashnikov rifles, they said.

Reuters journalists were shown a school and a mosque which had been hit by artillery or rocket fire, and also saw evidence of shells or rockets landing between houses in a residential area.

Residents said three people had been killed in attacks on the town by fighters from Zintan over the past 48 hours.