Libya's Congress elected a human rights lawyer as interim prime minister on Sunday, a week after his predecessor was sacked for failing to present a Cabinet line-up that political factions could agree on.

Ali Zidan, also a former independent congressman, won 93 votes, securing a majority of those who voted in a poll to determine the country's leader for a transitional period of around 20 months.

Zidan's top priority will be to name a new government that congress approves. The Cabinet will be faced with the daunting task of disarming thousands of young men who fought in last year's eight-month civil war that led to the capture and killing of longtime dictator Moammar Gadhafi.

The ministers will also be pressed to provide basic services, restore security by creating a military and police force capable of asserting authority over disparate militias left over from the war, and unifying the country's tribes and towns.

One such militia, a radical Islamist group that now claims to have dissolved, 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.

Feuds between cities and towns also flare up frequently. Militias are currently deployed on the outskirts of the mountain town of Bani Walid, one of the few remaining strongholds of Gadhafi loyalists. The possibility of an outbreak of violence there highlights the highly polarized atmosphere.

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 obtain.

The 200-member congress selected Zidan following last week's dismissal of Mustafa Abushagur after just 25 days in the post for failing to present a Cabinet list that satisfied legislators.

Some parliamentarians argued that Abushagur's Cabinet choices were not diverse enough, involved too many unknown individuals for key posts, and also had too many names from the previous interim government, which was seen by some Libyans as weak and corrupt.

Zidan was a diplomat under Gadhafi before defecting in the 1980s and joining Libya's oldest opposition movement, National Front for the Salvation of Libya, from Geneva where he lived.

On Sunday, he edged out Minister for Local Government Mohammed Al-Harari by just eight votes to win. Harari appeared to be the Islamists' choice for prime minister.

Zidan, born in 1950, holds a master's degree in international relations. He had previously run as a candidate for Libya's interim presidency, but lost to former opposition leader Mohammed el-Megarif by 28 votes in Congress.

The two biggest blocs in parliament, the Alliance of National Forces led by liberal wartime Prime Minister Mahmoud Jibril and the Muslim Brotherhood's political arm, The Justice and Construction Party, held meetings over the past week to try and agree on a candidate after Abushagur's dismissal.

Zidan had been Jibril's preferred candidate against el-Megarif for the post of president when he lost.

Saleh Gawdet, an independent congressman, said that the elected body had been searching for "a nationalist who does not belong to any party, but who served the country during the revolution."