Libyan delegates in Geneva chose Mohamed Menfi to head the Presidency Council of a new interim government and Abdul Hamid Dbeibah as its prime minister.
Musa Al Koni and Abdullah Al Lafi were also voted on to the three-man Presidency Council, in what was a surprising result that saw some of Libya's most prominent politicians fall by the wayside.
The UN-backed vote to choose a Libyan interim government had gone to a run-off on Friday at the Libyan Political Dialogue Forum, after none of the four candidate lists won enough support to secure outright victory.
The selection of an interim government is part of a UN peace process aimed at holding presidential and parliamentary elections in December. Libya has been mired in conflict after an uprising that led to the overthrow and death of dictator Muammar Qaddafi in 2011. Control of the country has been divided between a UN-recognised government in the west and an elected House of Representatives based in the east.
"The importance of the decision that you have taken here today will grow with the passage of time in the collective memory of the Libyan people," UN acting Libya envoy Stephanie Williams told the delegates.
"This process, your process, has come a long way from when we first convened you virtually in October of last year. You overcame your differences, divisions and the many challenges you have faced during this difficult, but fruitful journey, in the interests of your country and of the Libyan people.
"You understood the burden of your responsibility and the immense value of your contributions. You fulfilled your commitments before your constituencies," she said.
The run-off vote was between the list featuring Mr Menfi and Mr Dbeibah and a list with eastern-based parliament chief Aguila Saleh as head of the presidency council and western-based interior minister Fathi Bashagha as premier, which received the most votes in the first round.
All candidates for the new government have undertaken to hold national presidential and parliamentary elections on December 24 in which they will not stand for office, and to appoint women to 30 per cent of senior government roles.
The UN broadcast images of their signed pledges.
The UAE welcomed the formation of the interim government and praised the UN's efforts in bringing it about.
The Ministry of Foreign Affairs and and International Co-operation said the UAE offered its "full co-operation with the new authority in order to achieve security, stability, prosperity and the aspirations of the brotherly Libyan people".
Germany, France, Italy, the US and Britain also welcomed the new government but warned of a "long road" ahead.
"The unified executive authority will have to implement the ceasefire agreement, provide essential public services to the Libyan people, initiate a programme for meaningful reconciliation, address critical national budget needs and organise national elections," they said in a joint statement released by Germany's foreign ministry.
Ms Williams said the four competing lists formed among candidates on Thursday were diverse and represented Libya's potential.
However, some Libyans have been critical of a process which they view as being managed from abroad and which they fear will allow existing powerful figures to cling to their influence.
"It's just a painkiller to portray Libya as stable for a while. But war and tension will certainly come back sooner or later so long as militias have power," Abdulatif Al Zorgani, 45, a state employee in Tripoli, told Reuters.
The latest UN process emerged from a Berlin conference last year and gathered pace in the autumn after military commander Khalifa Haftar's eastern-based forces were pushed back from a 14-month assault on Tripoli.
It has also involved a military ceasefire but not all the terms of the ceasefire have been met, a sign of continued mistrust on both sides and internal fractures within both camps.
Many factions in the country are afraid to surrender influence they already hold, and with foreign powers invested in local allies, the new government may rapidly come under pressure.