Updated

The U.N. special envoy to Libya said on Friday that the museum attack in Tunisia adds a sense of urgency to the ongoing talks between Libya's rival factions and warned that the chaos in Libya could destabilize the whole region.

Since the ouster and killing of dictator Moammar Gadhafi, Libya has sunk into deep turmoil, torn by warring militias with rival parliaments on either end of the country claiming legitimacy and radicals from the Islamic State group taking root.

In neighboring Tunisia, authorities said the gunmen in the attack which killed 21 people on Wednesday were trained in Libya — raising the specter of spillover from that country's chaos wrecking Tunisia's fledgling democracy.

That is "another alarm to take into account ... it adds a sense of urgency," said U.N. envoy Bernardino Leon at the opening of the Libya talks near the Moroccan capital. "This should be a decisive moment because we are running out of time."

In Morocco, Libyan delegations will meet separately with Leon to discuss proposals for a national unity government and security arrangements to pull militias out of cities.

Leon said he hoped to have them agree on proposals by Sunday which would then be discussed by other negotiating tracks, including a meeting of armed groups sometime next week.

"They have to be ready to agree with each other, making concessions and not getting everything you want," he said.

Talks have dragged on for months in different venues with little results as fighting as heated up in Libya. Last week, the delegation from the eastern Libyan city of Tobruk — where the country's internationally-recognized parliament is based — refused to join the negotiations.

Leon said the international community is growing impatient with Libya's chaos and fears it could destabilize the whole region. "Terrorism is Libya is becoming a problem for Libyans and a problem for the region," he said.

Any agreement by the political factions, however, must also be accepted by various militias and warring military bands, including Gen. Khalifa Hifter in the country's east who has previously condemned the talks as discussions with "terrorists."