Libya's parliament elected Wednesday a leading member in the country's oldest opposition movement to be its new prime minister.

Mustafa Abu-Shakour is tasked with stabilizing a country where armed groups proliferate. Washington's ambassador to Libya and three other Americans were killed during a late Tuesday attack on the U.S. consulate in the eastern Libyan city of Benghazi.

Abu-Shakour, deputy to Libya's outgoing interim prime minister, is considered a compromise figure acceptable to both Islamists and liberals.

He is the first elected head of government since the ouster and slaying of dictator Moammar Gadhafi in last year's civil war.

He hails from the National Front Party, an offshoot of a longstanding anti-Gadhafi movement that includes both Islamist and secular figures. He narrowly beat liberal Mahmoud Jibril by 96 votes out of 190.

Previous interim governments have faced persistent criticism that they have been ineffective in tackling the multiple troubles facing the deeply divided nation, foremost among them the strength of armed militias that dominate towns and challenge the authority of the central government.

(This version CORRECTS Corrects PM's name and previous position. Adds details and background)