LA CELLE SAINT-CLOUD, France -- Two rival Libyan leaders committed themselves on Tuesday to a cease-fire, working toward presidential and parliamentary elections and finding a roadmap to secure lawless Libya against terrorism and trafficking of all kinds, according to a document released by the French presidency.

The meetings at a chateau in La Celle Saint-Cloud, west of Paris, brought together Fayez Serraj, prime minister of the U.N.-backed unity government, and Gen. Khalifa Hifter, the Egyptian-backed commander of Libya's self-styled national army. Macron met separately with each ahead of an encounter between the two Libyans in the presence of U.N.'s newly appointed special envoy for Libya, Ghassan Salame.

"There is political legitimacy is in the hands of Mr. Serraj. There is military legitimacy is in the hands of Mr. Hifter. They have decided to work together," Macron said.

Get Breaking News Delivered to Your Inbox

The 10-point joint declaration that capped the encounter was the first of its kind since Libya spiraled into chaos after the 2011 toppling and killing of leader Muammar Qaddafi.

Among the points agreed upon was a commitment to a cease-fire with armed force reserved "strictly" for use in counter-terrorism operations.

The rivals also "solemnly commit to work towards the holding of presidential and parliamentary elections as soon as possible."

General Khalifa Hifter of the Egyptian-backed commander of Libya's self-styled national army, left, France's President Emmanuel Macron, center, and Libya's Prime Minister Fayez al-Sarraj of the U.N.-backed government walk into the meeting room at the Chateau of the La Celle-Saint-Cloud, west of Paris, France, Tuesday, July 25, 2017. Philippe Wojazer/AP

The French president said later that the goal is for balloting in the spring. Serraj had said in May that elections would be held in spring.

"The stakes of this reconciliation are enormous. Enormous for the Libyan people, who have been suffering, living with instability and terrorist threats these past years, and it is considerable for the whole region," Macron said after the talks.

He continued, "Because if Libya fails, the whole region fails with it, especially directly neighboring countries. And it is process that is essential for all of Europe because if we don't succeed, the consequences affect our countries directly because of the terrorist risk and migration consequences."

Macron's bid to work toward laying the groundwork for a state with a functioning government and institutions is a priority of his presidency.

Talks were centered on creating a propitious climate for elections next year -- which the Libyan prime minister announced plans for in May -- security and military issues, respect for human rights and economic development of the oil-rich nation where residents struggle despite the resources, French officials said.

Macron, Salame and Serraj, along with French Foreign Minister Jean-Yves Le Drian, walked into the chateau to begin the first set of talks after shaking hands before Republican Guards in their ornate gear. Hifter arrived later.

The encounter was never expected to resolve the knotty problems of Libya, politically fractured and awash in militias and human traffickers preying on migrants who use the Libyan coast as a jumping off point to Europe, mainly Italy. But it was seen as a way to lay the basis for the U.N. envoy to come up with proposals in the weeks and months ahead.

Serraj and Hifter met in early May in Abu Dhabi, and the United Arab Emirates said later there had been a "significant breakthrough." Libya TV said the men agreed on holding presidential and parliamentary elections next year.

Paris has made clear that the French initiative is not meant to brush aside numerous initiatives by others, including the European Union, the African Union and individual countries, like Morocco.

France "wants to facilitate a political entente" and "mark its support for efforts to build a political compromise, under the auspices of the United Nations," that includes all actors in the country, a statement Monday by the president's office said earlier. The challenge, it added, is to "build a state capable of responding to the fundamental needs of Libyans" with one regular army "under the authority of civilian power," considered necessary for the control of borders and stability within Libya.