Rival factions in Libya have agreed to hold parliamentary and presidential elections on 10 December.
The four groups, meeting in the French capital, Paris, also agreed to adopt the necessary laws by mid-September.
French President Emmanuel Macron described the accord as historic and an essential step towards reconciliation.
Libya has been in a state of lawlessness since the toppling and killing of Colonel Muammar Gaddafi in 2011.
The North African nation is now controlled by disparate armed groups and fighting is continuing in the east and south of the country.
European leaders see stabilising Libya as key to tackling jihadist threats and migration from the country, which has become a departure point for hundreds of thousands of Africans trying to reach Europe.
Who agreed to the deal?
- Prime Minister Fayez al-Sarraj, (above second left) head of the UN-backed unity government based in the capital, Tripoli
- Khalifa Haftar, (above right) the 75-year-old military strongman , whose rival Libyan National Army fighters dominate the country's east
- Aguila Saleh Issa, (above second right) the parliament speaker based in the eastern city of Tobruk, who opposes the UN-backed administration
- Khalid al-Mishri, (above left) head of the High Council of State, Libya's highest consultative body formed from the 2012 parliament.
Representatives from EU countries, the US, and regional neighbours were also at the meeting hosted by the French president.
Tunisian President Beji Caid Essebsi told the Libyan leaders in Paris, "There is no solution other than via you... if things go badly, it's your responsibility."
Analysis: Will the election plan work?
By Rana Jawad, BBC North Africa correspondent
President Macron has walked away with one real achievement today - bringing together key rival Libyan blocs, as well as regional neighbours seen as exacerbating the conflict, like Egypt, Qatar and Turkey.
However, nothing was actually signed in Paris. Instead, Libya's rival representatives verbally agreed to a set of promises and dates - and diplomats tell me it "wasn't easy" to get them to do that.
There is a worry that giving the four big Libyan personalities a platform in Paris will only harden the views of other factions in Libya, triggering more divisions among the militias who nominally ally themselves to rival political institutions.
Invited representatives from the key western city of Misrata chose to stay away from the talks. Various militias from the west also said the talks don't represent them.
The success of today's agreement will rely on whether the rival armed groups allow the elections to take place and then respect the results. The last parliamentary election in 2014 plunged the country into a deeper crisis.