BENGHAZI, Libya — 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, 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 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 militants and two from the Shura Council, including Salem Derbi, the commander of the Abu Salem Brigade, which has a history of enmity with the Islamic State affiliate.
Meanwhile, in Berlin, the United Nations 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 UN 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 in 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 Islamic State group in Libya is a mixture of homegrown militants, former Al Qaeda affiliates, and foreign nationals trained in Syria and sent to join the Islamic State 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, said that among Islamic State members killed in Wednesday’s exchange was the group’s top ideologue Hossam Abu-Rashed.
The member added that many of those killed were 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 Moammar Khadafy. In a 2012 interview, Derbi said that under Khadafy, he hid in the mountains of Darna for over 10 years during a heavy crackdown on Islamic militants.
Darna was also the main source of Libyan jihadis and suicide bombers who joined the insurgency in Iraq after the US-led invasion in 2003. Entire brigades of Darna natives have also been fighting in Syria’s civil war.
An Islamic State 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.