Beheadings and racial tension: Life under Islamic State

Public flogging in Sirte Image copyright Islamic State
Image caption Islamic State militants have been carrying out public floggings in Sirte - and publicising them on social media

Just as the so-called Islamic State (IS) group seemed to be putting down roots in the Libyan coastal city of Sirte - its only stronghold outside Syria and Iraq - various forces began lining up early this year to remove it. By early June the city was surrounded.

BBC Monitoring looks back over the past four months to see what people have been saying on social media and what IS itself has been publishing as the campaign to retake the city developed.

8 February - IS dispenses death and donations; a rival emerges

It is one year since Islamic State seized Sirte. The group appears to be trying to demonstrate that it is in control by releasing a video showing its morality police enforcing their strict interpretation of Islamic rules, including one which demands that men wear their trousers short.

While it publishes pictures showing alms being handed out to the poor, IS also distributes images of public floggings. Pictures on social media show "crucified" corpses in the main roundabout after executions by IS.

Media playback is unsupported on your device
Media captionReligious police have been enforcing a strict interpretation of Islam

Meanwhile, Libyan prime minister-designate Fayez Seraj seeks to gain approval for a cabinet. The UN is encouraging him to bring order to a country in chaos since Muammar Gaddafi was toppled in 2011.

Libya is torn between two rival governments, one based in the east of the country and one in the west, allowing IS to prosper in the central area.

6 March - Car sales in the caliphate

IS wants to show that life goes on as normal in Sirte, posting images of public services department workers pruning trees, sheep-grazing, bee-keepers at work and an open-air showroom with dozens of cars on sale.

IS branches in Syria, Iraq and Libya regularly publish scenes of everyday life to recruit members and give the impression that they are effectively administering the land under their control.

Social media users, however, post pictures of people having fun on the beach in the days "before the terrorists arrived". "God willing, Sirte will return to how it was," says one user.

Communication between Sirte and the outside world is difficult, because of notoriously unreliable internet connections as well as IS restrictions. Some residents appear defiant, one tweeting: "I'm staying, #Daesh (IS), and I will continue to spread news of my city #Sirte to the world via Twitter, even if you cut our necks".

Screengrabs of Twitter feeds Image copyright Twitter
Image caption Several people have been recalling fond memories of the city, publishing pictures of the past with the hashtag #beloved_Sirte

9 March - New leader, same racial friction

IS names the new leader of its Libyan branch to replace his predecessor who was killed in a US air strike in November 2015. Shaykh Abd-al-Qadir al-Najdi is thought to be a foreigner, like his predecessors. His name suggests he is from Saudi Arabia.

The presence of foreign fighters is a source of friction, with locals complaining that the outsiders look down on them, and the IS fighters complaining of racism. One social media user asks: "Why does #Daesh prefer foreign commanders to Libyans?"

Weeks later, IS calls a reconciliation meeting between locals and foreign fighters.

The meeting is advertised in a flyer, which has been circulated on social media and which also invites city residents to the public execution of two of the group's own Libyan commanders, apparently to set a disciplinary example.

A separate IS letter to residents says racism towards foreign fighters will not be tolerated and warns the people of Sirte to show loyalty to the creed of Islam rather than to their tribe or city.

The author vows to "fix this Libyan problem before it is too late".

Africans depicted in IS training video Image copyright Islamic State
Image caption The presence of foreigners in Sirte, such as these pictured in an IS training video, has caused tension

Separately, an IS video featuring Sirte-based militants from Mali, Nigeria, Ghana and Senegal encourages West Africans to travel to Libya to join the group - another sign that IS may be struggling to co-opt locals.

23 March - IS celebrates Brussels attack

Following the bomb attacks on Brussels claimed by IS, the group's media arm shows pictures of sweets being handed out in Sirte in celebration of the assaults.

Days later the new "unity" government arrives in Tripoli.

Its arrival in the capital represents another stage in efforts to stabilise and unify the country which is split among rival factions, including IS. The ministers arrive by boat because opposing forces have blocked the city's air space.

18 April - Religious education, IS style

IS publicises the religious education of residents with pictures of a graduation ceremony for hundreds of ordinary people at a big conference centre in Sirte.

This appears to be the culmination of a major series of events that IS forced people to attend in an attempt to make everyone conform to its strict interpretation of Islamic law.

Some take to social media to complain.

According to local Twitter accounts, attendance of the course was mandatory for all males aged 15 and above, with all shops and businesses closed between afternoon and evening prayers, and movement in the street prohibited during this time.

One account said that two young men were arrested for failing to attend the course, but were released days later.

One tweet comments wryly that IS itself, rather than the local population, was "most in need of this kind of course".

IS religious education session in Sirte Image copyright Islamic State
Image caption IS publicity pictures show people attending a religious education session. Some people have raised objections on social media

2 May - Residents flee, IS gains territory

Amid reports of an impending military advance on Sirte, hundreds of families reportedly flee the city in the latest of several waves over recent months.

Al-Wasat website says fleeing residents told troops at roadblocks west of the city that their cars were searched by Libyan, Tunisian and Chadian IS members, who prevented them from taking their furniture, cooking utensils and gas cylinders.

Reports from the city suggest that the hospitals are barely functioning, the staff themselves having fled or staying away out of fear.

Over the next few days IS forces advance west towards Misrata, seizing territory including the strategic town of Abu-Qurayn, where they carry out a series of suicide attacks.

IS appears to be trying to seize the initiative to pre-empt any attack on its stronghold.

7 May - Central government announces push against IS

The unity government, having gained the support of some significant factions, announces the formation of a coalition to crush IS.

The anti-IS operation is headquartered in the town of Misrata, whose forces are a key component of the coalition.

Misrata has ample supplies of weapons and its fighters were crucial in the overthrow of Gaddafi.

The Misrata militia also has Islamists leanings - like many of the other militia - and has been accused of brutal behaviour.

The headquarters soon starts reporting battlefield developments to local TV channels and posting updates on its Facebook page under the name Operation Solid Structure, a reference to a Koranic verse which is often invoked by IS itself.

8 May - Not-so-compliant tribes

IS publishes pictures supposedly showing tribal leaders pledging their support for the self-styled caliphate.

However, it becomes clear that these large tribes - Wlad Sliman, Warfala and Gaddadfa - won't or can't provide realistic support to IS with reports over the next few days of clashes between tribesmen and IS militants in nearby towns.

An informant from the town of Abu Hadi, a few miles south of Sirte, tells the Libyan news website Al-Wasat that young men from the Gaddadfa tribe had attacked a convoy of IS "Islamic Police" hunting for tribesmen.

There have been numerous reports in Libyan media saying that since it took root, IS has dealt harshly with these tribes.

IS militants reportedly arrested and executed scores of Gaddadfa tribesmen, the people of former leader Gaddafi.

The large Warfala tribe has reportedly seen many of its towns taken over by IS, and tribesmen who had worked for the police, military or judiciary have been executed.

Cartoons by social media user @LibyanLemons Image copyright LibyanLemons
Image caption Social media user @LibyanLemons has been poking fun at IS with cartoons, one of which, on the right, goes with the words: "Welcome to Allah's paradise on earth - Sirte! Our hearts are black but our streets are clean!"

17 May - Government gains valuable ally

The government in Tripoli manages to convince one the most successful commanders in eastern Libya - Lt Al-Mahdi al-Barghathi - to become minister of defence.

On his way to assume his duties in the capital, he visits the strategic oil port of Sidra and secures the support of the Petroleum Facilities Guard (PFG) - the men who are supposed to guard Libya's oil wealth, but who have turned into a rogue private army.

Their support is key to encircling Sirte from the east, while militia from Misrata attack from the west. The odds are now stacked in favour of Operation Solid Structure.

21 May - 'We'll fight to the death'

A defiant message from IS spokesman Abu-Muhammad al-Adnani appears to prepare supporters for the loss of one of its strongholds. He mentions Sirte alongside Raqqa in Syria and Mosul in Iraq, underlining the importance of its Libyan bastion.

"Will we be defeated if we lose Mosul or Sirte or Raqqa or all the cities and go back to how we were before? No. Defeat is only losing the desire and the will to fight."

He warns that IS will fight to the death, enacting a scorched earth policy in the event of being dislodged from any of its strongholds.

30 May - Sirte surrounded

The government-led advance recovers towns from IS to the east, west and south before entering Sirte.

Within days the anti-IS forces, surprised by their own progress, corner IS militants holding out in a small area in the centre of the city.

19 June - Radio war

Operation Solid Structure announces that it has started test broadcasting on an FM frequency previously used by IS's Al-Bayan Radio. The unity government-backed forces claim that they have been jamming IS radio.

Since the beginning of June, fighting between the two sides has continued with IS carrying out a series of suicide bombings and government forces bombarding IS positions in the centre of the city.

BBC Monitoring reports and analyses news from TV, radio, web and print media around the world. You can follow BBC Monitoring on Twitter and Facebook.