Updated

Libya President Mohammed el-Megaref has ordered rogue militias to disband by Tuesday, an effort to regain control of the country amid violence and armed attacks, including one that killed four Americans, according to news reports.

The president reportedly made the announcement late Saturday and said the effort to disband the illegitimate groups would be a joint-operation between the official army and authorized militia brigades.

He said others operating outside the "legitimacy of the state" are to be disbanded, according to Reuters.

An attack Sept. 11 by members of those rogue groups on the U.S. Consulate in the eastern city of Benghazi killed U.S. Ambassador Christopher Stevens and three other Americans.

El-Megaref made the decision amid public anger over the armed factions and Islamic extremists, resulting in the storming of some of their compounds by protesters.

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

The groups were given 48 hours to evacuate military compounds, state property and properties of members of the former regime in Tripoli and surrounding areas.

The army ordered "all individuals and armed groups occupying military compounds, public buildings or property belonging to members of the former regime to evacuate these sites within 48 hours,'" threatening to use force if the groups did not comply, the official LANA news agency reported Sunday.

El-Megaref’s announcement came after the Islamist Ansar al-Sharia militia was swept out of its bases in Benghazi on Friday, according to The Associated Press.

The armed groups that still control large parts of Libya more than a year after the overthrow of Muammar Qaddafi.

The invasion of Ansar al-Sharia's compounds was reportedly met with little resistance.

On Saturday, two Islamist militias in the eastern town of Derna, an Islamist stronghold, announced they were disbanding and evacuating their compounds, residents told the Associated Press.