Libya's prime minister and his cabinet have resigned to make way for a new government based on parliamentary elections held in June, a government statement said.

Abdullah al-Thinni's cabinet said on Thursday that it had resigned according to Libya's constitutional rules to allow the new House of Representatives to form a government based on all parts of society.

The House of Representatives replaced the General National Congress in June, but was forced to move to Tobruk in the far east of the country to escape a month of street fighting in the capital, Tripoli.

Armed factions mainly from the northwestern city of Misrata expelled from the capital a rival group from Zintan, and have pushed to reinstate the previous parliament, the GNC.

Islamists were much stronger in the GNC than in the new assembly dominated by liberal and federalist politicians.

Thinni was appointed in March, but has faced opposition and a government teetering on collapse for much of his tenure. The Islamist-leaning Ahmed Maetig was appointed prime minister following a breakdown of parliament in May but his position was later ruled unconstitutional and Thinni was reinstated as caretaker in June.

"This is just a routine step. There is no conflict between Thinni and the House of Representatives," an unnamed politician told the Reuters news agency.