Libya's president has ordered the disbandment of "illegitimate" militias, a move designed to assert state authority amid violence by armed groups, including an assault on the U.S. consulate in the eastern city of Benghazi that killed the U.S. ambassador.

Libya's army has given the groups 48 hours to evacuate military compounds, state property and properties of members of the former regime in Tripoli and surrounding areas, the official LANA news agency told Reuters on Sunday.

In a news conference on Saturday, President Mohammed el-Megaref said a joint operations room in Benghazi will co-ordinate between the various authorized militia brigades and the army. He said others operating outside the "legitimacy of the state" are to be disbanded.

The decision came amid growing public anger at armed factions and extremists, resulting in the storming of some of their compounds by protesters.

But in the absence of strong security forces, the government relies on some militias to keep order.