Libya's parliament has sworn in a new prime minister, officials have said.

Libya's National Conference elected 42-year-old businessman Ahmed Maetig on Sunday with 121 votes, second deputy speaker of parliament Saleh al-Makhzoun told the AFP news agency.

"I swear I will carry out my duties honestly and in devotion," Maetig told parliament as several seats appeared empty.

After a chaotic session of parliament, Maetig was initially reported to have mustered only 113 votes of the 120 needed under the constitution in a vote of confidence.

But Makhzoun said Maetig had in fact clinched 121 votes, apparently after a recount, beating off challenger Omar al-Hassi, a university professor.

"Ahmed Maetig is officially the new prime minister," Makhzoun said as some politicians immediately challenged Maetig's appointment by shouting.

Fatma al-Majbari, an MP, told Libyan TV station Al-Ahrar there were no violations and new votes came after the session was adjourned.

Maetig has been given two weeks or sooner to form a new government.

Libya's 185-seat interim parliament has been deadlocked and unable to impose authority after Abdullah al-Thinni resigned as prime minister three weeks ago, citing an attack by gunmen on his family.

Thinni resigned just one month after his election, when he replaced Ali Zeidan who was voted out of office after rebels humiliated the government by shipping crude on a tanker without government permission. The tanker was ultimately seized by US forces and returned to the country.

Libya has seen a severe deterioration in security since the end of Muammar Gaddafi's decades-long rule in 2011.

Source: Agencies