Sirte (Libya): Sheltering in tunnels, improvised bunkers and rooms fortified by sand-filled fridges, IS is holding out in the Libyan city of Sirte, defending itself with snipers, booby-traps and car bombs against pro-government forces.
After a six-month campaign of often fierce street fighting, IS militants are surrounded in a district less than one-kilometre square, after hundreds of US air strikes that began in August in support of Libyan forces.
The battle for Sirte, taken by IS more than a year ago, may be over soon. But how the militants managed to survive may give insight into the kind of tactics they could use to defend other cities.
The fall of Sirte would mean the loss of the militant organisation's main stronghold outside Iraq and Syria just as a US-led alliance supports Iraqi forces moving to retake the city of Mosul, its main base in Iraq.
Sirte fell to IS as the militants profited from infighting among Libyan factions to gain territory, steadily taking the city and imposing their hardline vision on Muammar Gaddafi's former home town.
A UN-backed government is now in Tripoli trying to unite Libya's competing factions of armed brigades who once battled together to oust Gaddafi in 2011, but have since turned against one another.
Six months ago, powerful brigades from the nearby city of Misrata began a campaign to flush the militants out of Sirte, which posed a direct threat to their city.
In the early days of the battle, Misrata forces suffered heavy casualties from snipers. More than 500 Misrata fighters have been killed, many by gunshots as they pushed in from the city outskirts.
Fighting has ebbed and flowed along with casualties as Misrata forces slowly encircled the last districts under IS control, leading militants to change to more hit-and-run tactics, car bombs and explosive devices.
Some Misrata commanders said progress had been slowed by snipers and explosive devices left behind, but also by a lack of weapons and hospital facilities, especially when heavy fighting led to casualties in double digits.
But US air strikes since August have targeted car bombs and militant firing positions, allowing progress. Western special forces teams are advising on the ground as well as providing forward air controllers who guide air strikes.
"Each round of fighting has its own circumstances... and it's difficult to predict when the battle will be over. But the end of Daesh (IS) will be very soon," said Mohammad Ghasri, a spokesman for pro-government forces.
With Misrata forces closing around the city centre midway through the campaign, militants at first appeared to be holed up in the Ouagadougou conference hall, a central complex once used by Gaddafi for African summits.
As US air strikes intensified, militants pulled back into dense residential neighbourhoods as the battle destroyed much of the city. But it has been a fighting withdrawal, taking a toll on Libyan forces.
At the end of August, 35 Misrata brigade fighters were killed as their forces moved forward several hundred meters among emptied residential blocks in neighbourhood Number One, near the sea front.
Now with less than one square kilometre under their control, militants have the sea front on one side and Misrata forces all around them, controlling high ground over part of the 600 district and the Ghiza Bahriya area, witnesses said.
Abandoned houses have revealed some of their defences: Household fridges packed with earth act as reinforcements, and bunkers dug under foundations offer protection from air strikes.
Last week, Misrata forces found improvised tunnels and a makeshift field hospital. A Reuters witness said that in one house graffiti on the walls indicated a quick escape route for the next fighter to use that hideout.
Improvised bombs made from fragmentation grenades and rocket shells are common traps.
Garages often contain unexploded car bombs, a Reuters reporter on the ground said. Suicide belts are sometimes left behind by fleeing fighters.
Misrata forces have also been increasingly using tanks and heavily armoured vehicles to approach buildings, blasting a way ahead before brigade fighters, some often in flip flops and jeans, make their way in to clear them.
On Thursday, five foreign captives - two Turks, two Indians and a Bangladeshi - were freed after fighting that killed 20 IS militants. Losing captives may be a sign of the group coming under more pressure. But it also makes Misrata forces cautious.
"Sometimes the battle takes a long time because we face unexpected situations like civilians being detained," Rida Issa, another spokesman said. "The battle is now in residential areas and that means tough, street-by-street fighting."
How many militants are left in Sirte is unclear. At the start of the campaign, some estimates said as few as 600 fighters remained. Some commanders and militants may have already fled before Sirte was encircled, Misrata officials say.
That has raised the risk of guerrilla attacks. Already a suicide bomber has hit a field hospital outside the city. This week more roadside bombs were found near a field hospital and a helicopter landing area 5 km (3 miles) outside Sirte, witnesses said.