* Chaotic session ends with discord over new premier
* Analysts see appointment unlikely to ease turmoil
* Libya has struggled politically since 2011 war
Businessman Ahmed Maiteeq was sworn in as Libya's new prime minister on Sunday after chaotic voting but parliament's deputy speaker hours later declared the election invalid as a power struggle erupted in the assembly.
The divisions in the assembly showcase growing turmoil in the North African country where government and parliament are unable to assert authority in a country awash with arms and militias from the 2011 ouster of Muammar Gaddafi.
Officials gave contradicting versions of the parliamentary election outcome, with First Deputy Speaker Ezzedin al-Awami initially saying Maiteeq had failed to obtain the necessary quorum even through he emerged as front runner in prior votes.
But a power struggle over who controls the assembly broke out when second deputy speaker Saleh Makhzoum rejected Awami's claims and said Maiteeq had won the necessary support.
"Ahmed Maiteeq is officially the new prime minister," Makhzoun told a televised session interrupted by shouts from lawmakers challenging his win. He asked the businessman to form a government within two weeks.
But hours later, Awami declared the vote invalid and instructed Abdullah al-Thinni, who had resigned three weeks ago, to continue ruling the major oil producer.
"Mr Ahmed Omar Maiteeq failed to reach the quorum of 120 votes necessary according to the law to elect a new prime minister," Awami wrote in a letter to Thinni posted on the cabinet website.
It was unclear what would happen next as both speakers then argued with each other live on al-Ahrar television station with Makhzoum insisting Maiteeq had been elected. "From a legal point of view the vote process was right and clear," he said.
Analysts expect Maiteeq, if confirmed, to struggle to make headway as the government is unable to control militias who helped topple Gaddafi but now defy state authority.
Since the civil war that ended Gaddafi's one-man rule, Libya's nascent democracy has struggled, with its parliament paralysed by rivalries and brigades of heavily-armed former rebels challenging the new state.
The premier's post became vacant after Thinni resigned, citing an attack by gunmen on his family just a month into his term.
Parliament began voting on his successor on Wednesday, but that session was postponed after gunmen linked to a defeated candidate stormed the building and wounded several people.
Lawmakers resumed voting on Sunday in a frequently interrupted session, marked by confusion over the number of votes cast for Maiteeq.
"The vote ... to appoint him as the prime minister was totally invalid," said lawmaker Zainab Haroun Al-Targi, echoing the views of many colleagues.
Thinni's short-lived tenure followed that of Ali Zeidan who fled the country after he was fired by deputies over his failure to stop attempts by rebels in the volatile east to sell oil independently of Tripoli's government.
Libya's General National Congress (GNC) assembly is deadlocked between Islamists, tribes and nationalists, as the country's fledgling army tries to assert itself against unruly ex-rebels, tribal groups and Islamist militants.
In February, it agreed to hold early elections in an effort to assuage Libyans frustrated at political chaos nearly three years after the fall of Gaddafi.
Many people in the OPEC nation blame congressional infighting for a lack of progress in the transition to democracy. Libya still has no new constitution.
Assembly president Nouri Abu Sahmain was absent from the vote. He has disappeared from public view since the attorney general launched an investigation into a leaked video showing him being questioned over a late-night visit by two women to his house.
In another sign of chaos, tribesmen ended a two-month protest at the key El Sharara oilfield but output will only resume after a separate protest at a connecting pipeline is resolved, an oil official said.
A wave of protests from militias, tribesmen and state security guard at oilfields and ports has reduced oil output to a trickle from 1.4 million barrels per day in July.