A Libyan Islamist militant alliance joined forces with local people in Derna to drive back Islamic State fighters, capturing the group's Yemeni commander and retaking a city courthouse, local residents said on Saturday.
Earlier in the day, a suicide bomber blew himself up in Derna, killing at least three people and wounding five more as rival militants fought on the streets. A second bomber also detonated his explosives later but there were no casualties other than the bomber, who died.
Islamic State loyalists, who have been expanding their foothold in the North African country, have been engaged in fierce fighting for control of Derna for a week with local Islamist umbrella group Majlis Mujahideen.
Confirming developments is difficult in Libya, where two rival governments and their armed forces are fighting for control, leaving a power vacuum militant groups have exploited to expand their influence.
But local residents say Majlis Mujahideen, with local armed people, have pushed Islamic State out of much of Derna, taking back the courthouse, and killing several of the group's fighters including an Egyptian.
Fighting was continuing in the city center, with most shops and businesses closed. Islamic State is mostly in the Ras El Hilal and Fattiah areas of the city, residents said.
Derna, a conservative city where Islamist hardliners resisted Muammar Gaddafi before his 2011 fall, was the first place Islamic State tried to gain support in Libya.
The group recruited from other militant groups, slowly implemented sharia law, banning public smoking and shisha pipe cafes. The Yemeni, who locals believe to be named Abu El-Bara El-Azadi, arrived in Derna late last year as a representative of Islamic State's Iraqi leadership.
But the group also faced competition from locals with more domestic agendas. Majlis, which is linked to former rebel groups who fought Gaddafi, enjoys local support going back to the revolution.
Fighting erupted last week when a Majlis commander was killed and the group declared a holy war against Islamic State fighters in the city.
European states have grown particularly alarmed at Islamic State's expansion beyond its strongholds in Iraq and Syria to a chaotic country just across the Mediterranean sea from mainland Europe and with little control over its porous borders.