Thousands flee as fighters battle on the outskirts of Tripoli’