Libya’s first unity government in seven years was sworn in before parliament on Monday, as efforts to end a decade-long conflict in the North African oil producer stepped up.

The new government, which replaces two rival administrations and faces huge challenges, offers the chance of an end to the chaos that has engulfed Libya since Muammer Gaddafi was overthrown after a Nato-backed uprising in 2011. That uprising morphed into a multi-layered conflict that sucked in regional powers and divided the country.

The main task of the new administration — which emerged from UN talks — is to prepare Libya for elections in December, the first since nationwide polls in 2014 helped plunge the country into conflict.

“Today’s swearing-in session illustrates the eagerness and the determination of Libyans to overcome their differences, work for a better future for all,” said Jan Kubis, the UN special envoy for Libya.

Claudia Gazzini, senior analyst at the International Crisis Group, described it as a “historic step”. “The simple fact that they were able to get a vote of confidence from rival members of the House of Representatives [parliament] is a massive step forward.”

Progress at the talks stepped up after the military defeat of Khalifa Haftar, the renegade general from eastern Libya who tried to overthrow the UN-backed government in Tripoli and seize power. He was armed by the United Arab Emirates, his forces were bolstered by Russian mercenaries and he received backing from Egypt and France. But Turkish military support for Tripoli helped rout Haftar’s forces in June 2020 and a ceasefire was announced in October.

Since Haftar’s defeat, there has been a “regional de-escalation” and “a change of rhetoric from Egypt, Turkey and Qatar,” said Gazzini.

Abdul Hamid Debeibeh, the new interim prime minister and one of the country’s richest men, has already been received in Cairo by Abdel Fattah al-Sisi, the president — a sign of Egyptian support, analysts say.

Turkey, which Egypt has had strained relations with since 2013, has been signalling in recent weeks a desire for warmer relations with Cairo. Egypt and Qatar, on opposing sides of the Libyan conflict, have also restored ties as part of a wider regional reconciliation in January between Qatar on one side and Saudi Arabia, the UAE and Egypt on the other.

Debeibeh still faces massive hurdles to knit the divided country together and bring it to elections scheduled for December 24. Foreign forces are still present on Libyan soil and there is no indication when they will depart. He has to unite divided institutions including the central bank and address issues around the sharing out of oil revenue. Another massive task is the unification of the military and making progress on the demobilisation of militias which hold sway in many parts of the country.

“A big challenge is the reunification of the divided military,” said Gazzini. “There is still no defence minister and the militia issue will take time and a concerted effort in order to root out the disturbing armed groups on both sides of the divide.”

Members of the government took the oath of office in the city of Tobruk in eastern Libya before the House of Representatives and will start work in Tripoli in western Libya from Tuesday.