A pro-government fighter walks in the range of Islamic State sniper fire in Sirte, Libya. (Lorenzo Tugnoli for The Washington Post)

The black flag of the Islamic State flutters above a two-story house that serves as a sniper’s nest. The deserted street is under its control, as are all the nearby buildings. The banner and the occasional crack of the marksman’s bullet are the only signs of the militants on this afternoon.

Two blocks north, less than a football field away, Libyan militiamen are gathered with handheld rocket launchers and Mad Max-style pickup trucks mounted with large machine guns. Since last Monday, U.S. airstrikes have pounded Islamic State targets in this battered seaside city, the stronghold of the Middle Eastern militants’ Libyan affiliate. Yet the pro-government militia forces have not crossed this front line.

“If we move forward, their snipers will be firing at us like hell,” said Suleiman Shwairf, a pro-government fighter, peering at the flag from behind a wall Friday.

The American air intervention has altered the military equation on the ground and given a much-needed boost to the morale of the fighters battling the Islamic State, also known as ISIS or ISIL. But in a densely packed urban environment, where territory is seized street by street and house by house, eradicating the militants from Sirte remains a formidable struggle, illuminating the limits of the U.S. air campaign.

The fall of Sirte could be a major setback to the ambitions of the Islamic State. But since May, when the campaign to liberate Sirte began, the militias have been confronted with a sophisticated and coordinated strategy used by Islamic State fighters to protect their bastion in Sirte’s urban center. Hundreds of pro-government fighters have been killed or wounded by buried mines, explosive-laden doors, tripwire bombs, suicide attackers and snipers. The Islamic State remains in control of roughly 70 percent of the city’s urban area over a stretch of four miles.

In the Islamic State stronghold of Sirte, pro-government fighters are just yards from the militants. (Lorenzo Tugnoli for The Washington Post)

In their first week, U.S. airstrikes mostly targeted Islamic State tanks and armored personnel carriers, as well as mobile ammunition depots and rocket launchers. Now, the Islamist fighters are altering their tactics to counter the air assault, hiding their military vehicles, moving command posts frequently, and staying out of sight during the day, according to pro-government commanders.

“The armored personnel carriers, the tanks are not their strongest weapons, anyway,”said Mohamed Darat, 45, the top commander for the largest front line in the city. “Their strongest weapons are the land mines, booby-traps and the snipers. Those are the biggest problems we face.”

Still, of the several thousand Islamic State militants initially in the city, most have either fled or been killed. Only an estimated 500 to 1,000 remain, and they are surrounded — by pro-government forces on land and by Libyan vessels patrolling the sea. Add the American air support, and a long-term hold on Sirte by the militants seems implausible.

The questions many Libyans ask: When will the city fall? And at what human cost?

‘Inhuman ways to kill’

In early 2015, the Islamic State seized parts of this sprawling metropolis in the heart of Libya’s oil crescent, home to most of its petrochemical resources. The birthplace of Libyan dictator Moammar Gaddafi, the city was the last major stronghold of his loyalists during the revolution five years ago that toppled his regime. Gaddafi was killed here by rebel fighters in October 2011.

The Islamic State within a few months swiftly consolidated its grip on Sirte, using it as a base to stage attacks on oil facilities and other targets. With pressure growing on the militants’ parent body in Syria and Iraq from U.S. airstrikes and attacks by Iraqi forces, Sirte was viewed as a possible fallback capital of the Islamic State’s self-declared caliphate.

It was those ambitions that triggered the current fighting here. When Islamic State fighters advanced west up the coast in May, militia brigades from the nearby city of Misurata counterattacked. Within days, they had pushed the militants back inside Sirte, retaken the outer suburbs of the city and moved into the urban zones. Small groups of American and British elite troops helped target Islamic State positions with surveillance drones and other technology.

Then their advance into the city center slowed.

The Islamic State forces, a mix of foreigners and Libyans, were pummeling the brigades with tank and artillery fire. The land mines and snipers were planted on streets and at hospitals, universities and other large complexes. The militants had cached weapons, as well as supplies of food and water, in different parts of their territory.

The militants also are using creative ways to kill. They have jury-rigged refrigerators to blow up when militia fighters search houses. Bombs are planted inside bags of bread and left in visible places for their enemy to pick up. They have transformed baby monitors into voice-activated bomb triggers, and used paper clips touched together to ignite explosives.

“They are using the most devious and inhuman ways to kill our fighters,” said Darat, a former civil engineer.

In the past three months, some 400 militiamen have died, with more than 2,000 injured, according to doctors at a military field hospital outside the city. There was also anger and frustration among the fighters, who had felt that the United States and the West had abandoned them by not taking stronger actions to help them combat the Islamic State.

The mounting casualties and military stalemate in the city prompted Libya’s Western-backed national unity government to request the U.S. airstrikes last week.

“Now, we’re friends,” said Ahmad Mletan, 35, a doctor at the military field hospital.“The American support legitimizes our cause. We feel we are no longer alone, and the international community is with us.”

But on the front lines, the U.S. intervention, while welcome, remains bittersweet.

“It’s a little late,” Darat said. “If the Americans started supporting us from the beginning, we would have saved so many lives.”

The effect of U.S. airstrikes

The road into Sirte from the west is littered with the debris of war. Charred cars from a suicide bombing. Aging Soviet-made tanks, some stalled in the sand. Walls covered with the graffiti of myriad militias.

Inside, Sirte is a ghost city.

Nearly its entire population of 80,000 has fled. Buildings are pocked with grapefruit- size holes from artillery rounds. Houses have been shattered by crossfire. Locked-up shops and businesses have black stamps on their walls reading in English and Arabic: “Office of General Services.”

The stamps are from the Islamic State tax collection department.

In one neighborhood, pro-government fighters took down a large iron frame at a traffic circle where the militants used to execute residents, hanging them up as in a crucifixion and then shooting them. In another enclave, they found an Islamic State prison where detainees were tortured and a grave that contained nine bodies, Darat said.

The militants are now entrenched in several large urban neighborhoods and in the Ouagadougou conference center,which Gaddafi once used to host African Union meetings and other international summits.

Al-Dollar, a residential enclave so named because of its opulent mansions, has become the primary front line. Militia fighters have taken over the empty houses, moving in mattresses and supplies, and setting up rooftop firing positions.

Roads are blocked by stacked shipping containers that mark the boundaries between the Islamic State and the militiamen. Signs read: “Danger. There are snipers.” And two days before the U.S. airstrikes began, a suicide bomber blew himself up in front of a house, steps from Darat’s command center. On Friday, pieces of the assailant’s body were still on the ground.

The U.S. airstrikes have helped Darat’s men to some degree. He said that last Monday, he coordinated with the Misurata military operations room working with the U.S. forces to call in a strike on an Islamic State sniper’s nest in a house. And on Wednesday, he asked for an attack on an antitank gun. In both cases, he said, “our American friends” struck the targets.

Only 10 mortar rounds have landed in al-Dollar since the U.S. campaign began. The week before, the enclave was regularly struck by tank fire, rockets and other artillery. Now that has all disappeared. The Islamic State fighters are keeping a low profile, apparently waiting out the air campaign, Darat said.

Still, on Thursday, a militant sniper killed a militia fighter here. And on Friday, a bullet from an Islamic State position hit a nearby mosque, prompting the militia fighters to return fire with heavy machine guns.

Land-mine barrier

What Darat wants most is to cross the main road, less than 200 feet from his command center, and push farther into Islamic State territory. On the other side of the road, the militants control a hospital complex and a hospitality center once used by Gaddafi to host dignitaries.

But the area is sown with land mines and booby traps.

And Darat is running out of mine specialists. His best engineer was killed recently when he tried to move a corpse. Islamic State fighters had planted a bomb under the body. Many of Darat’s remaining mine specialists are either traumatized or unwilling to push forward into Islamic State territory.

He recently considered sending 1,000 sheep across the road to get blown up by the mines — and clear the way. But he decided that would be too brutal, he said.

And as U.S. airstrikes keep targeting Islamic State weaponry, there could be an unexpected consequence. Darat’s intelligence operatives have noticed more militant fighters moving at night. And that, he fears, could make his goal of crossing the road more complicated.

“Now, Daesh knows they can’t use so many heavy weapons against us without the Americans attacking them,” Darat said, using the Arabic acronym for the group. “They will plant even more land mines. They are running out of options.”