TUNIS, Dec 9 (Reuters) - Libyan forces are trying to secure the city of Sirte after ousting Islamic State from its former North African stronghold in a battle that lasted nearly seven months.
Here are some facts about Islamic State in Libya:
Islamic State drew on existing pockets of militancy in Libya, establishing its first major presence in Derna, an eastern city with a strong Islamist tradition.
It also profited from a security vacuum caused by the turmoil that followed Libya's 2011 revolution, and from 2014 a conflict between loose alliances of armed groups loyal to factions based in Tripoli and the east.
In October 2014 militants from al Qaeda-linked group Ansar al-Sharia who largely controlled Derna announced they were transferring their loyalty to Islamic State. Ansar al-Sharia members in several other parts of eastern and central Libya also switched allegiance.
Jihadists who returned from fighting in Syria with the Libyan al-Battar battalion also made up part of the jihadist group's initial presence in Libya.
Senior emissaries were sent to the country by Islamic State's leadership in Iraq, including former leader Abu Nabil al-Anbari, Bahraini preacher Turki Bin Ali, and Saudi national Abu Habib al-Jazrawi.
Islamic State affiliates appeared in several places in eastern Libya including Benghazi, the country's second-largest city, and Ajdabiya, close to some of Libya's main oil export terminals.
In Sirte, hometown of late dictator Muammar Gaddafi, Islamic State took full control in early 2015. The group eventually extended its presence along a coastal strip of about 250 km (155 miles) either side of the city.
Islamic State also established a presence in parts of Libya's vast southern desert, and built up sleeper cells in urban centres in northwestern regions including the capital, Tripoli.
Sabratha, a coastal city in the far west, became an important hub for Tunisian members of the jihadist group plotting attacks in their home country.
In many areas, however, Islamic State struggled to expand or retain territory. In Derna, the group was chased out by rival Islamists and other opponents, and in Sabratha local brigades took on militants in February in the wake of a U.S. air strike.
Many of those appointed to senior positions in Islamic State's Libyan branch were foreign, drawing on large numbers of recruits from countries including Tunisia, Egypt and Sudan, according to security and intelligence officials in Misrata.
Some senior figures were dispatched from the Middle East. These included Wissam Abd al-Zubaidi, also known as Abu Nabil al-Anbari, a former intelligence official and IS governor from Iraq who arrived in Libya in 2014 to lead operations there and was killed in a U.S. air strike in Derna in November 2015.
In March, Islamic State publication Al-Naba named Abdul Qadr al-Najdi as the new leader. Najdi is thought to be the new name for Abu Habib Jazrawi, a Saudi earlier dispatched to Libya by Islamic State's leadership in Iraq. Regional media reported that he was recently replaced by a Tunisian, Jalaludin Al-Tunsi.
Keen to fight the perception that it was a foreign import, Islamic State also placed Libyans among its leadership in the North African country. A number of senior Libyan figures were killed during the battle in Sirte.
Among the first major attacks claimed by Islamic State in Libya was a January 2015 armed assault on the luxury Corinthia Hotel in Tripoli in which nine people were killed, including foreigners.
In the weeks that followed, Islamic State released videos of dozens of Christian hostages from Egypt and Eritrea being beheaded and shot in mass executions, two of which were carried out on beaches.
From February 2015, the militants also targeted Libya's oil facilities, causing extensive damage and further reducing the oil production on which the Libyan economy is highly dependant. In January 2016, attacks against major oil terminals at Es Sider and Ras Lanuf caused significant damage to storage tanks.
The same month, a bombing targeting police recruits in the north-western town of Zliten killed about 60 recruits, the highest death toll from a single attack since the 2011 uprising.
In early May the jihadists pushed north-west from Sirte towards Misrata, briefly capturing the small town of Abu Grain and several villages in the area. That advance triggered the counter-attack that developed into the campaign to recapture Sirte.
As in Syria and Iraq, militants set up a proto-state in Sirte, registering and taxing local businesses and taking over public offices and services.
Islamic State also enforced its ultra-hardline rule on Sirte's residents, prompting many who had not already left the city to flee. Smoking was banned, barber shops closed, women and teenage girls were made to wear long black robes, and boys were trained as fighters.
There were regular public punishments. Suspected thieves had their hands chopped off and residents accused of spying were shot dead, their bodies put on public display for several days.
Writing by Aidan Lewis; Editing by Pravin Char