ROME — Global powers on Sunday backed the formation of a national unity government in Libya, pledging economic and security support to help stabilize the chaotic North African country where Islamic State militants have a foothold.

U.S. Secretary of State John Kerry and Italian counterpart Paolo Gentiloni, joined by U.N. envoy Martin Kobler, were optimistic that the majority of the representatives of Libya’s two rival governments would sign a unity deal on Dec. 16.

Representatives from 17 countries including Egypt, Germany, Russia, Turkey and China signed a joint statement calling for an immediate ceasefire and promising to cut off contacts with factions that do not sign the deal.

Fifteen Libyans from different groups also attended the meeting. Past deadlines have slipped amid internal disagreements in the sprawling, oil-producing country rife with armed groups.

“We stand ready to support the implementation of the political agreement and underline our firm commitment to providing the Government of National Accord with full political backing and technical, economic, security and counter-terrorism assistance, as requested,” the statement said.

Both Kerry and Gentiloni, who co-chaired the meeting, appeared confident a deal was around the corner, and stressed that a unity government was needed also to fight the growing threat from Islamic State militants.

“The message of today’s meeting is clear,” Gentiloni said. “What matters is the stabilization of Libya because this too can contribute to the fight against terrorism.”

Libya has sunk deeper and deeper into chaos since a Western-backed rebellion toppled Muammar Gaddafi four years ago.

Former colonial power Italy has sought to focus international attention on the OPEC country’s drift towards anarchy, particularly since last month’s deadly Islamic State attacks in Paris. Libya is less than 190 miles across the Mediterranean Sea from the Italian island of Lampedusa.

Islamic State

With about 3,000 fighters, Islamic State has solidified its foothold in Libya by taking over the central city of Sirte. It has attacked a hotel and a prison in Tripoli, oil fields and military checkpoints, and issued a video of its militants beheading 21 Egyptian Christians on a Libyan beach.

The U.N. brokered agreement would allow a new Libyan government to ask for international military assistance to fight Islamic State’s growing presence.

The recognized government and elected House of Representatives have operated only in the east of Libya since last year, when the capital Tripoli was seized by a faction that set up its own government. Each side is backed by competing alliances of former anti-Gaddafi rebels.

The U.N. proposal calls for a presidential council with the House of Representatives as the legislature alongside a second consultative chamber, the State Council.

The presidential council could form a government in 30 days once a deal is signed and that would be ratified by parliament and bolstered by a U.N. Security Council resolution.

But with Libya already fragmented, questions linger about how opponents and armed factions which might reject the deal will react to what they will see as an unrepresentative government, and how they can be brought on board after.

“We are prepared to meet with [the national unity government] rapidly in order to facilitate their capacity to govern,” Kerry said.

Any government faces huge challenges, with the oil industry reeling from attacks and protests. Output is less than half of the 1.6 million barrels per day the OPEC state had before 2011.

Western officials do not rule out more unilateral airstrikes on militants. The United States has carried out airstrikes and France has conducted surveillance flights.

But with most in the West opposing troop deployments on the ground, initial efforts will likely focus on training and aiding local forces.