Italy's government has asked the European Union to come up with contingency plans for a possible mass movement of refugees fleeing the fighting in Libya as diplomats struggle to rein in the burgeoning civil war for control of the country's capital.

The move came as human rights groups condemned a "horrific" attack by soldiers on migrants caught up in fighting in southern Tripoli.

Amnesty International said Tuesday's assault on the Qasr Ben Ghashir detention center, which hold 890 people, should be "investigated as a war crime."

The UN said 12 people needed hospital treatment after "armed actors" breached the compound.

At least 264 people have been killed and more than 1,200 wounded since April 4, when General Khalifa Haftar, the head of the Libyan National Army which controls eastern Libya, launched an assault on Tripoli, the seat of the internationally recognised Government of National Accord.