Libyan political factions called Thursday for the urgent formation of a national unity government in their war-torn country, wrapping up two days of talks in Algeria that UN sponsors called positive.
Their final declaration came a day after UN's Libya envoy told them the "country really is at the limit" and risks becoming a failed state.
Libya plunged into chaos after a 2011 NATO-backed uprising toppled and killed long-time dictator Moamer Kadhafi, with heavily armed former rebels carving out their own fiefdoms across the country.
At the same time, two sets of parliaments and governments have been contending for control over the country, where the Islamic State jihadist group has recently made major inroads.
The declaration expressed concern about the "upsurge in terrorist acts" and the IS takeover of some territory and the "imminent danger it poses to the stability and security of the country.
It "stressed the need to stand united in confronting this danger."
Signup to our newsletter and follow us on Facebook and Twitter!
The declaration called for a comprehensive and balanced agreement to "move quickly to form a government of national accord that can swiftly assume its responsibilities to tackle the many difficult challenges facing Libya on the security, political and economic levels."
UN Support Mission in Libya chief Bernardino Leon told journalists after the meeting ended that "it is still possible to save Libya," and that he is working on a draft final agreement.
On Wednesday, he exhorted the parties to acknowledge their common interests, particularly their fight against the Islamic State group, and to stop demanding new concessions of each other.
Speaking in Qatar a day earlier, Leon said he believed that 75 per cent of political leaders in the strife-torn country wanted peace.
"I think we will see an opportunity (for peace)," he added. "Most groups are now supporting a political solution."
Three rounds of talks have so far taken place in North Africa, but failed to bring peace.
During April talks in Morocco, Leon and other negotiators said the sides were very close to an agreement on a draft proposal to form a national unity government that would serve for a maximum of two years.