SIRTE, Libya (Reuters) - After six months of heavy fighting, Libyan forces have advanced so deep into the strategic city of Sirte that they can pick out the Tunisian and Egyptian accents of their Islamic State enemies as they trade insults over the frontline.
Victory is imminent on this remote front of the war against Islamic State, with the last few militants staging a last stand in a small area of just one square kilometer (0.4 square mile), U.S. and Libyan officials say.
Related: The battle to reclaim Mosul from ISIS
But the battle has been long and hard, and holds lessons for U.S. backed forces trying to force Islamic State out of the much larger Iraqi city of Mosul more than 2,500 km (1,500 miles) away.
"We faced unbelievable resistance. They won't leave their posts even when houses are collapsing on them," said Osama Issa, a 37-year-old businessman fighting with Libyan forces in Ghiza, the last neighborhood of Sirte that Islamic State holds.
"They know they will die anyway so they fight well."
Defeat in Sirte will damage Islamic State's ability to show it is expanding globally and deprive it of a foothold outside Iraq and Syria. Losing it and Mosul in quick succession would dent its morale and possibly its ability to recruit followers.
But the militants in Sirte have inflicted heavy losses on the Libyan fighters -- at least 660 have been killed and 3,000 wounded -- and held out longer than expected.
They have proved their skills in guerrilla warfare, shown the vulnerability of advancing forces that lack expertise in urban warfare and highlighted the limited effectiveness of air strikes when frontlines are so close.
The battle has also underlined the importance of trapping fighters during battle because many have escaped from Sirte -- a Libyan commander put the number at 400 -- and are now staging attacks behind frontlines with increasingly sophisticated bombs.
Growing rivalry between the various factions in the Libyan forces also serves as a warning to the diverse groups fighting Islamic State in Mosul: the end of the battle may bring political chaos and the risk of new military conflicts.
Islamic State gradually took over Sirte from early 2015, taking advantage of the chaos in Libya since the start of a civil war in which long-time ruler Muammar Gaddafi was overthrown in 2011.
Sirte, Gaddafi's former hometown, became its main base in North Africa. Just as in Iraq and Syria, militant commanders began to impose their strict vision on Sirte, banning shisha pipe smoking and forcing woman to wear all-covering robes.
Later, they enslaved migrant women, imposed taxes and meted out punishments such as public whippings and crucifixions.
Related: US soldiers in Mosul
Forces from the nearby city of Misrata, aligned with the U.N.-backed government in the capital Tripoli, started the military offensive to recapture Sirte in May after Islamic State threatened their security.
The last jihadists are holding out in the Ghiza neighborhood of the Mediterranean port city, using improvised tunnels, booby traps and snipers.
Hiding among collapsed rooftops and in rubble-packed streets in Ghiza, they have sand-filled fridges and tunnels which provide protection against shelling and air strikes.
The Libyan forces have been backed by hundreds of U.S. air strikes and helicopter raids, and small teams of U.S. and British military advisors. They are now using Soviet-era tanks to blast paths through rubble as they go from house to house, trying to end the militants' resistance.
"We hear them at night shouting to us, telling us they are coming for us," said Asruf el Qat, a student fighting in the rubble of Ghiza's many collapsed villas. "It's snipers, and landmines. We advance, they throw grenades. It's a dirty war."
Sniper fire crackled as Qat's brigade kept watch though holes in walls, and occasional shells whistled overhead.
Another brigade armed with AK-47 assault rifles -- some of them older men in uniform, others students in jeans and flip flop shoes -- prepared to flush out a sniper holed up nearby.
Islamic State leader Abu Bakr al-Baghdadi called this month for jihadists to travel to Libya. It was not his first call for Libya recruits -- Tunisians, Sudanese and Egyptian fighters fought in the city. But Sirte as a base is finished.
"Sirte was supposed to be a fallback from Iraq and Syria. That's now gone," said Geoff Porter at North Africa Risk Consulting. "Strategically, the Islamic State could point to Sirte and tell its followers that it really was global and growing. It can't do that anymore."
Misrata intelligence officials say there were once 2,500 militants in Sirte, the majority of them foreign jihadists.
Sirte is now largely deserted. No life has returned to the outer districts of a city of 80,000 residents, where buildings are pockmarked with shell craters and bullet holes.
Few signs of Islamic State's rule remain. A large Libyan national flag now flies at the Zafaran roundabout, where militants once crucified victims. Islamic State tax symbols are still spray-painted on shop walls.
The Libyan forces are mostly civilians who fought Gaddafi and returned to help against Islamic State -- students, mechanics and former army officers among them.
"Maybe it will take a week or two from what I can see now (to end Islamic State's resistance in Sirte)," said Salah Al Houti, 22, a student fighting with the Libyan forces. "They stocked supplies and food underground."
Libyan commanders say their advance has been slowed by casualties and a lack of ammunition, and complain they received none of the night vision equipment and other weaponry they asked for their allies to deal with snipers.
Fears about trapped civilians, at times used as hostages, have increased caution about air strikes and shelling.
"It has been the same situation as in Iraq and Syria. They (Islamic State) are using tunnels and using civilians as human shields," Misrata intelligence chief Brigadier Mohamed Gnaidy said.
"They are professional fighters. Their objective is to kill as many of us as possible."
NEW BATTLES AHEAD?
Libyan commanders hope victory in Sirte will remove the threat of Islamic State across the whole country.
But the fighters who escaped before Sirte was completely surrounded are still a threat. Some may have fled south, potentially reinforcing links between Islamic State and militant groups in the arid Sahel region, including Nigeria's Boko Haram, and Al Qaeda in the Islamic Maghreb.
Others now stage guerrilla attacks near Sirte with devices detonated by remote control. They had previously used long wires to trigger roadside bombs or planted landmines.
Another growing problem is the rivalry among fighting groups. Some are turning their attention to renewed fighting with other factions to the east, where Khalifa Haftar, a former Gaddafi ally, is leading the Libya National Army force that does not recognize the Tripoli U.N.-backed government.
Haftar's forces took over four key oil ports from a rival faction this year. He has allowed oil exports to reopen for the National Oil Corporation but many in Misrata see him as a military strongman in the making.
"I fought in three wars, and the fourth might be against Haftar, and who knows about a fifth," said Abdulminam Abu Breda, a car mechanic who fought in battles for the control of Tripoli and is now fighting in Sirte.