Libya's elected parliament has tasked the recently resigned prime minister with forming a new government as the outgoing cabinet acknowledged it had lost control of the capital to Islamist-allied militias.

The official news agency said the parliament convening in Tobruk voted today to name Abdullah al-Thinni as the new head of an 18-portfolio cabinet, of which seven ministries would form a "crisis government".

Mr Al-Thinni resigned on Wednesday, saying he hoped a new government would be more inclusive.

His government was at odds with an alliance of Islamist militants who took over the capital, Tripoli, from rival groups after weeks of fighting. Dozens were killed and thousands fled the capital, including the government, which set up a base in the east, as well as residents and foreign diplomats.

In a statement late on Sunday, the outgoing government of Mr al-Thinni said it had lost control of almost all state institutions and government offices to armed militias. The statement said some of those buildings were "occupied", others "stormed", and staff and employees had been prevented from entering.

"It has become dangerous for (employees) to get to their work places without the risk of being detained or killed especially after some of the armed groups issued direct threats against them, attacked and torched their homes and terrorised their families," the statement said.

The Tripoli house of Mr al-Thinni himself was attacked and torched. His government has resided in the east, in Bayda, following the outbreak of fighting.

The militias in control of the capital, operating under an umbrella group called the Dawn of Libya, have also taken control of the US embassy compound in the capital, a week after they drove out rival militias. A US State Department official said the compound "remains secure".

Libya's divisions are rooted in rivalries between Islamists and non-Islamists, as well as powerful tribal and regional allegiances between groups who quickly filled the power vacuum after the 2011 fall of longtime dictator Muammar Gaddafi. Successive transitional governments have failed to control the militias.

The outgoing parliament, led by Islamists, has refused to recognize the newly elected body that convenes in the east. It has also separately named a new prime minister to form a "national salvation government".

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.