ROME -- Diplomats trying to help Libya emerge from the chaos that terrorists have exploited said Sunday that rival political factions in the North African country need to accept an immediate cease-fire and embrace a U.N.-brokered plan aimed at creating a "secure, democratic, prosperous and unified state."

"We refuse to stand by and watch a vacuum filled by terrorists because all of us are unwilling to do what's necessary to help people who want their freedom, want their independence, want their country back," U.S. Secretary of State John Kerry said after a conference that drew officials from 17 countries, the European Union, the African Union, the Arab League and the United Nations, as well as 15 Libyan leaders.

Members of Libya's two rival parliaments are set to sign the agreement, mediated by U.N. special envoy Martin Kobler during a session Friday in Tunisia, at a ceremony Wednesday in Morocco.

Libya slid into chaos following the 2011 toppling and killing of dictator Moammar Gadhafi. Since then, it has been torn between an internationally recognized government in eastern Tobruk and an Islamist-backed government in the capital, Tripoli, and now faces threats from Islamic State extremists.

IS is trying to extend its influence beyond areas it now controls, including the city of Sirte. The envisioned government of national accord is seen as critically important to help restore security and mobilize international support to counter the extremists.

The plan for a national unity government "is not something being sprung on the people of Libya," said Kerry, who hosted the conference with Italian Foreign Minister Paolo Gentiloni.

"This has been developed by Libyans" through lengthy negotiations and "deserves to breathe the air of a future and of freedom and of possibilities."

Gentiloni has pressed other countries to move faster and with more urgency on Libya, which lies just across the Mediterranean from Italy's southern shores. "The commitment taken by all today can really be a turning point in a crisis that has dragged on for so long, with all the risks that that carries for all of us," he said.

A joint statement issued after the conference urged "all parties to accept an immediate, comprehensive cease-fire in all parts of Libya" and pledged economic, security and counterterrorism assistance for the unity government.

Conference participants reaffirmed their commitment to Libya's sovereignty and territorial integrity, and rejected "any foreign interference in Libya. We stand behind the Libyan people's efforts to transform Libya into a secure, democratic, prosperous and unified state, where all its people can be reconciled, (and) state authority and the rule of law are restored.

The U.N. plan calls for the creation of that government within 40 days. It would give the Libyans until early February to form a presidency council that would appoint a cabinet, including chiefs of the central bank and national oil company, and begin the process of moving the Tobruk-based parliament back to Tripoli.

Libya's oil industry has been largely crippled by the crisis. Proper management, as well as that of the central bank, is considered essential to the country's viability.

The plan would extend the reconstituted parliament's term by one year and allow for an automatic one-year extension of its mandate beyond that, if necessary.

The U.N. Security Council is expected to approve of the agreement shortly after it is signed by the Libyans.

"I was impressed by the consensus of the people of Libya to end the division, to be united as one country, not to be subject to terrorist threats and this is the wish of the Libyan people now," Kobler said at a news conference.

The United Nations and many countries concerned about Libyan crisis and the rise of IS stepped up efforts to get the rival governments to accept the power-sharing agreement since the factions rejected the deal in October.

Despite the political breakthrough, Kerry said "we are under no illusions about the difficulty inherent in the road ahead. ... It takes times to overcome the legacy of four decades of dictatorship which robbed Libya of any kinds of institutions of government that are legitimate."

Associated Press writer Frances D'Emilio contributed to this report.