| CAIRO/BENGHAZI, Libya
CAIRO/BENGHAZI, Libya Islamic State jihadists have exploited widespread chaos to gain a foothold in Libya, but their ejection from an eastern city suggests they may not achieve a Iraq-style takeover due to strong local rivals and the absence of sectarian divisions.
Last month, local Islamist fighters reinforced by local civilians ousted Islamic State militants from Derna on Libya's eastern Mediterranean coast, one of two bastions the jihadists had established in the North African oil-producing country.
It was the first setback in Libya for the ultra-violent jihadist movement that has sent in combatants and clerics from Tunisia, Yemen and other Arab states to try repeat its success in Iraq and Syria, where it has captured vast territories and proclaimed a "caliphate" based on medieval religious precepts.
Islamic State (IS) has benefited from Libya's anarchy. Two rival governments are fighting each other and unable to gain the upper hand while former rebel groups that helped topple Muammar Gaddafi in 2011 compete for power, creating a security vacuum.
But IS was driven out of Derna after seven people were killed at a protest against the influx of foreign jihadists and the killing of a commander of the local Abu Salim Martyrs Brigade, allied with a former anti-Gaddafi militia in the town.
A number of angry residents joined the Abu Salim Martyrs to help them expel IS from Derna, an Islamist hotspot even during Gaddafi's 42-year rule in which he suppressed political Islam.
The Sunni Islamic State has drawn considerable grassroots support in Iraq and Syria by milking longstanding Sunni-Shi'ite Muslim sectarian enmities. But this does not work in Libya, an exclusively Sunni country where local Sunni armed factions and tribes regard Islamic State as an infiltrator and competitor.
"People had had enough of Daesh," said a Derna resident, using a derogatory Arabic acronym for Islamic State, also known as ISIS and ISIL. "The Abu Salim Brigade has enjoyed some support going back to the (anti-Gaddafi) revolution."
Mattia Toaldo, policy fellow at the European Council on Foreign Relations, said Islamic State would now probably focus on its other Libya power base -- Sirte, Gaddafi's hometown on the country's central coast where IS has won unusual support from Gaddafi loyalists opposed to Libya's jostling new rulers.
IS insurgents have attacked oil fields south of the central city and kidnapped some nine foreign workers. They also executed 21 Egyptian Christians near Sirte and stormed a luxury hotel in the capital Tripoli, killing five foreigners.
Toaldo said he expected the jihadists would try to set up checkpoints at a strategic central junction where the east-west coastal highway links with a passage to Sabha, a city in Libya's far southern desert. "They would be able to ask for a lot of protection money (there)," he said.
Unlike in Iraq and Syria, Islamic State has been unable to earn millions by selling oil on the black market because it is dominated by Libyans. IS therefore relies on ransoms paid for abducted prisoners and on state salaries paid to local members in Libya, where most adults remain on the state payroll.
DERNA BATTLE NOT OVER
Islamic State might also try tap into grievances in the impoverished south. Neither rival government has any authority in the remote, desolate area where dozens have been killed since last week in clashes between two tribes, the Tuareg and Tebu.
"Islamic State-linked militants may seek to take advantage of feelings of marginalization in the southwest, particularly among members of the Tuareg ethnic group, to recruit fighters and hold territory," said Geoffrey Howard, Middle East and North Africa analyst at London-based Global Risk Analysis.
As for Derna, Islamic State has confirmed in a video that it has pulled out its fighters. But the fighting is not over yet.
Military units loyal to Libya's internationally recognized government based in the east since losing control of Tripoli a year ago to a rival group said they had now surrounded Derna.
"Islamic State aren't many and they don't have petrol to move around," said Abdul Karim Sabra, a local military spokesman. "They don't have military vehicles either. They get around in fertilizer trucks."
But clashes between Islamic state and eastern army units aligned with the internationally recognized government outside Derna, and several car bombs going off inside the city, killing 10 people and blamed by residents on Islamic State, suggest the military encirclement has not been effective.
Islamic State can always seek refuge in the Green Mountain hinterland -- a hideout for independence hero Omar al-Mukhtar for years when fighting the then-Italian colonial regime.
Since the eastern army units and the Abu Salim fighters treat each other as enemies, and as long as these regional military forces do not try to venture into Derna, it may well remain a playground for radical Islamists.
"It's a crowded field," said Frederic Wehrey, Senior Associate at the Carnegie Endowment for International Peace. "Everything in Libya is fragmented, everything is localized, so it's difficult for any group to expand."
It also remains to be seen whether life will improve for people in Derna. "Shops and banks have reopened (since IS pulled out) but there is lack of medicine in hospitals," said the local resident, who asked not to be named for his own safety.
(Editing by Mark Heinrich)