Al Qaeda-linked militants in eastern Libya declared holy war -- or jihad -- on the local Islamic State affiliate after one of their senior leaders was killed Wednesday by masked gunmen, which set off clashes between the rival groups that left 11 people dead on both sides, including a top militant commander.

The hours-long fighting in the eastern coastal city of Darna erupted after gunmen opened fire on Nasser Akr, an Al Qaeda-inspired militant once held in the United Kingdom on terrorism charges. The 55-year-old veteran jihadi, who fought in Afghanistan, was killed along with his aide.

Akr's group -- known as Shura Council of Darna's Jihadis -- announced his death in a statement Wednesday, blaming it on Islamic State militants. It accused the IS fighters of "tyranny and criminality," and vowed to wage "holy war against them until none of them are left." It also called on residents to rise up against the extremist group.

The ensuing clashes killed at least nine ISIS militants and two from the Shura Council, including Salem Derbi, the commander of the so-called Abu Salem Brigade, which has history of enmity with the ISIS affiliate.

Meanwhile, in Berlin, the U.N. envoy to Libya urged the North African country's rival political groups to agree quickly to a power-sharing deal for their fractured nation, saying that time is running out for Libya.

"The time has come to make an agreement," said Bernardino Leon, the U.N. envoy leading talks aimed at stemming Libya's collapse into a failed state.

Libya is split between an Islamist-led government backed by militias that seized the capital of Tripoli last August and its elected parliament, which is forced to convene in the country's far east. Amid the crisis, militants -- including the extremist Islamic State group and Al Qaeda-linked militants-- have gained a foothold, benefiting from the chaos.

The IS group in Libya is a mixture of homegrown militants, former Al Qaeda affiliates and foreign nationals who were trained in Syria and sent to join ISIS in Libya.  The clashes in Darna mirrored regional rivalry between the two groups, which are also fighting against one another in Syria.

A member of the Abu Salem Brigade, who spoke on condition of anonymity because he was not authorized to talk to the media, told The Associated Press that among IS members killed in Wednesday's exchange was the group's top ideologue Hossam Abu-Rashed.

"Now we are searching for the Wali," the Brigade member added. He was referring to a Yemeni militant sent from Syria to fight for Libya's ISIS affiliate and known by his nom de guerre Abu al-Baraa el-Azdia.

The member added that many of those killed are foreign nationals.

The slain Abu Salem Brigade commander, Derbi, belonged to a generation of Islamic militants who turned Darna into a jihadist stronghold in the 1980s and 1990s during an insurgency against longtime dictator Muammar Qaddafi. In a 2012 interview with the AP, Derbi said that under Gadhafi, he hid in the mountains of Darna for over 10 years while a heavy crackdown on Islamic militants was underway.

Darna was also the main source of Libyan jihadis and suicide bombers who joined the insurgency in Iraq after the U.S.-led invasion in 2003. Entire brigades of Darna natives have also been fighting in Syria's civil war.

An IS affiliate seized control of Darna last year after veteran militants returning from Iraq and Syria united the city's fractured extremist factions and killed off rivals, including members of Derbi's militia.

Libya's turmoil accelerated last year when militias allied with Islamist factions seized Tripoli and the second largest city of Benghazi, forcing the elected parliament and government to relocate and reconvene in the country's far est.

ISIS fighters have also taken the central coastal city of Sirte and are marching toward the third largest city of Misrata in western Libya and toward the oil terminals in the east.

In Darna, ISIS has set up its own religious courts and police to inforce a strict interpretation of Islamic law, or Sharia.

Hamad al-Bondoqi, a Darna lawmaker in the country's elected parliament, said that Al Qaeda-linked groups and the ISIS affiliate have clashed repeatedly in the past months in Darna, mostly over power and resources. He cited battles over imposing taxes on merchants, fighting for control of a local factory, and over who has the right to set up checkpoint at the southern entrance to the city.

Later in the day, al-Bondoqi said that an airstrike by government forces targeted the courthouse in Darna where ISIS has based their religious police, but missed and hit a nearby house, killing at least five members of the same family.