Saudi Arabia has closed its embassy in Libya as the country's army chief ordered a powerful Islamist militia group to deploy in Tripoli, after the parliament was stormed by troops loyal to a renegade general.

"All the diplomatic staff has left the Libyan capital aboard a private plane due to the security situation through which Libya is passing," Saudi ambassador Mohammed Mahmoud al-Ali said.

Violence erupted over the weekend as gunmen led by Gen. Khalifa Hifter assaulted the parliamentary building, in the capital in what the army and congress denounced as an attempted "coup". Two people were reportedly killed and more than 50 wounded.

General Khalifa Haftar
General Khalifa Haftar Reuters

The attack followed clashes last week between Hifter's forces and Islamist militias in the restive eastern city of Benghazi, which authorities said killed 70 people.

Hifter said he sent his troops there to purge the city of Islamists and restore order.

In turn, parliament speaker and commander in-chief of Libya's armed forces, Nouri Abu Sahmein - an Islamist-leaning politician - has ordered the Libya's Central Shield militia to move against Hifter's troops.

Libya's Central Shield is an umbrella group dominated by Islamist militiamen from the county's largest city, Misrata.

To add to the escalating tension, also an al-Qaida-inspired extremist group, known as the Lions of Monotheism, vowed to take up arms against Hifter.

"You have entered a battle you will lose," a masked militant, identifying himself as Abu Musab al-Arabi, said in a video posted online by the Lions of Monotheism.

Libya has been in turmoil ever since the removal of Muammar Gaddafi from power two years ago.

Frictions between Islamist and non-Islamist parliamentary factions backed by lawless militias have resulted in a fragile central government which has been struggling to rule a country fragmented by conflicting tribal loyalties and fill the security vacuum left by the 2011 revolution against the dictatorship of General Gaddafi.