Libya's parliament on Sunday ousted the country's newly elected prime minister in a no-confidence vote, the latest blow to hopes that the country's factions could agree on a government charged with restoring stability after last year's civil war.

Mustafa Abushagur was Libya's first elected prime minister after last year's overthrow of dictator Muammar al-Qaddafi. He represented an offshoot of the country's oldest anti-Qaddafi opposition movement, and was considered a compromise candidate acceptable to both liberals and Islamists.

But his proposed Cabinet was struck down by a legislature representing dozens of divided tribes, towns, and regions across the country, many of whom feel they are owed the spoils of victory over Qaddafi. He was forced to withdraw his first ministerial line-up under pressure and his second attempt to submit one resulted in his ouster.

In a short statement on Libya al-Wataniya TV after the vote, Abushagur said he respected the decision made by the General National Congress as part of Libya's democracy but warned of instability if it takes too long to elect his replacement.

"There should be quickness in the election of the prime minister and formation of the government so the country does not slip into a vacuum," he said.

He had 25 days from his Sep. 12 appointment by parliament to form a Cabinet and win the legislature's approval, but that deadline expired on Sunday. The Congress voted 125 to 44 in favor of removing him as prime minister, with 17 abstaining from voting. He had just put forth 10 names for key ministerial posts Sunday when the no-confidence vote was held.

Until a replacement can be elected by the parliament, management of Libya's government is in the hands of the legislature.

The Congress will have to vote on a new prime minister in the coming weeks. The incoming leader will be responsible for rebuilding Libya's army and police force and removing major pockets of support for the former regime.

On Sunday, around 1,000 people protested in the capital Tripoli outside the congressional headquarters to demand that militias operating alongside the army end a partial siege of the town of Bani Walid, considered a major stronghold of former regime loyalists. They called for a peaceful solution to the standoff that has already sent families fleeing from the town in anticipation of a strike.

Perhaps the single greatest challenge facing any new Libyan leader is the proliferation of ex-rebel militias. One radical Islamist militia has been linked to the attack last month on the U.S. Consulate in the eastern city of Benghazi that killed the American ambassador and three others.

There has been a widespread popular backlash against militias since that attack, and the Libyan government has taken advantage of it to try to put some armed groups under the authority of military officers. But some militias have resisted any attempt to fully control them or disarm them.

Any prime minister who wants to impose his authority on the militias will need broad national support for his government -- but such support is hard to get.

Some parliamentarians argued that Abushagur's Cabinet list was not diverse enough and involved too many unknown individuals for key posts. His first proposed Cabinet makeup was also criticized for including too many names from the previous interim government, which was seen by some Libyans as weak and corrupt.

After 40 years of Qaddafi's divide-and-rule tactics and the 2011 war, Libya's towns, tribes and regions are highly polarized. Many feel entitled to high government positions because of their losses in the war against Qaddafi, and are wary of any power wielded by their rivals.

In an indication of the charged atmosphere, Abushagur withdrew the initial line-up for government after the parliamentary chamber was stormed on Thursday by protesters from the city of Zawiya -- one of several cities that took the brunt of Qaddafi's attacks during the war -- demanding representation. Lawmakers left the General National Congress floor, saying they would not vote under pressure.

Before the vote of no-confidence, Abushagur said he was aiming to create a government of national unity that did not appoint ministers according to "quotas."

"The government I proposed is not perfect and was marred by some mistakes, so I changed it for the purpose of national unity," he said.

Independent lawmaker Nizar Kawan, who is aligned with the Muslim Brotherhood in Libya, said the group's party and a liberal coalition led by former rebel prime minister Mahmoud Jibril had been holding talks about replacing Abushagur with an independent figure who has no political background. The candidate would then be tasked with forming a government that is run by well-known professionals and is politically balanced and geographically representative.

Abushagur had taught engineering at the University of Alabama for about 17 years before leaving in 2002. He was active in the opposition abroad against Qaddafi prior to last year's uprising.

According to Libya's transition plan, after the formation of a government a new constitution is to be written and voted upon in a national referendum.