Libya conflict: Rival lawmakers sign deal in Morocco Published duration 17 December 2015

media caption The moment the deal was signed

Libya's rival politicians have signed a UN-brokered deal to form a unity government in a nation split by more than four years of conflict.

UN envoy Martin Kobler described the deal as historic, saying Libya had "turned a page" in efforts to achieve reconciliation and stability.

However, the heads of the rival parliaments failed to sign the deal because of major disagreements.

Armed groups which control much of Libya were not part of the talks.

Libya has been in chaos since the 2011 overthrow of long-serving ruler Muammar Gaddafi by Nato-backed forces.

It has two rival governments, one based in the main city, Tripoli, and the other about 1,000km (620 miles) away in the port city of Tobruk.

Analysis: Rana Jawad, BBC North Africa correspondent

image copyright AFP

The signing draws a line under a 14-month political process that gained more prominence in recent months because of the large influx of refugees and migrants to Europe, and the growing threat of Islamic State militancy in the country.

Diplomats put extra pressure on the Libyan delegates in recent weeks because in order to address those issues they need a single government to work with.

Some observers sounded alarm bells ahead of the signing, cautioning that it could further divide Libya if it did not include all the key players - and not everyone was present at the ceremony in Morocco.

A security plan to protect the new unity government - which at the moment only exists on paper - is crucial, and this does not exist.

This latest step is a huge gamble.

It could yet prove to be a springboard for a wider agreement that eventually unites Libya.

But if it fails, it may lead the country into a darker spiral of violence over legitimacy and control.

'Difficult journey'

Amid the turmoil, the country has become a major departure point for some of the thousands of migrants travelling to Europe from Africa.

There is also international concern that the militant so-called Islamic State (IS) group is taking advantage of the instability to expand inside Libya.

Mr Kobler said the new government would have to tackle the dire humanitarian situation in Libya, and fight IS and other jihadi groups.

"You must not forget that this is the beginning of a difficult journey. There is a critical need for national reconciliation [in Libya]," he told the rival politicians.

Around 80 of the 188 members of the Tobruk-based parliament and 50 of the 136 rival lawmakers in Tripoli signed the deal, the AFP news agency quotes participants as saying.

image copyright Reuters image caption Militias which ousted the former regime are now fighting among themselves

On Tuesday, the heads of the two parliaments, Agila Salah of Tobruk and Nouri Abusahmen of Tripoli, said they had not authorized anyone to sign the agreement on their behalf.

Mr Salah pleaded for more time, warning that "acting hastily would lead to more problems in the future".

Mr Abusahmen said "we will not accept foreign intervention against the will of the Libyan people" referring to the UN-backed deal.

The two leaders met for the first time in Malta on Tuesday.

Mr Salah's parliament is internationally recognised, and based itself in Tobruk after being driven out of Tripoli.