The UN envoy for Libya has announced a national unity government for Libya after months of talks between the North African country's two rival governments.

Bernardino Leon told reporters late on Thursday that the names of candidates for the national unity government have been decided.

Leon said the prime minister for the new government is Fayez Sarraj, a member of the Tripoli-based administration.

"We believe this list can work," Leon said of the names, which include three deputies for the prime minister - representing the country's east, west and south - and two ministers to complete a presidential council.

"All of them will work as a team," Leon said. He added, "This was not an easy task."

Negotiators who attended the peace talks representing the rival governments approved the names of candidates, but the parliaments for both sides must approve them, too.

Mohamed Eljarh, an analyst at the Atlantic Council's Hariri Centre for the Middle East, said this seemed "very unlikely" as there had been a lot of negative reaction on both sides.

Rival administrations

Libya has had rival administrations since August last year, when an alliance of militias from the city of Misrata known as Libya Dawn took over the capital, Tripoli.

The group drove out the internationally-recognised government, which now operates in the eastern city of Tobruk.

UN Secretary-General Ban Ki-moon welcomed the proposal of a unity government in a statement issued by his media office, while urging the parties to accept and sign the agreement.

The statement said Ban "urges Libyan leaders not to squander this opportunity to put the country back on the path to building a state that reflects the spirit and ambitions of the 2011 revolution".

The foreign policy chief of the European Union, Federica Mogherini, also welcomed the announcement.

Stumbling blocks in the process have been the disbanding of militias as well as the removal of former general Khalifa Haftar - the military commander for the Tobruk parliament, which is recognised by the UN and the Arab League.

Al Jazeera's Diplomatic Editor James Bays said the new government, if approved, would face "immense challenges" in governing the country, which has been in turmoil since Muammar Gaddafi was toppled and killed in 2011.

"The two main factions only reluctantly agreed to the deal, and there has been so much bloodshed and political bad blood that there are many across the political spectrum who oppose it," he said.

"There are fighters and militias who are unlikely to obey the new government."

The government will also have to deal with the threat of the Islamic State of Iraq and the Levant (ISIL) group, which has gained a foothold in Gaddafi's former hometown, Sirte.

The country has porous borders and is awash with arms. It has also become a hub for smugglers who prey and refugees trying to make the dangerous journey across the Mediterranean to Europe.

Source: Al Jazeera and agencies