The Kurdish fighters who recently captured this city were impressed to glimpse for themselves a warren of tunnels and underground bomb shelters built by now-vanquished Islamic State occupiers, describing it as a feat of engineering.

The extremist group, which captured the northern Iraqi city of Sinjar in August 2014, has built tunnels in other parts of Syria and Iraq where it administers a self-declared caliphate. But Sinjar is one of the few places where Islamic State has been forced to retreat, offering outsiders a rare view of how the group marries meticulous planning with brutal tactics, such as using the local population as slave labor to fortify conquered territory.

“There are so many tunnels we can’t count them,” Kurdish Yazidi officer Maj. Hussein Khuru Murad said Monday. “This one let them go in and out of a shop on the street, and then make their way to a bomb factory,” he added, pointing to an entrance in the city center.

Throughout territory held by Islamic State in Iraq, the group has built tunnels. In Beiji, home of a key oil refinery and near the cities of Fallujah and Tikrit, Iraqi Army and Shiite militiamen have said they have come across tunnels. The militants used them to burrow under an enemy position to plant explosives, create underground bunkers or run pipe to export illicit oil shipments.

In the end, the intricate underground infrastructure the militants built in Sinjar wasn’t enough to prevent a determined Iraqi Kurdish ground force known as the Peshmerga from routing them with the help of the U.S.-led airstrikes. Peshmerga fighters liberated the city on Friday after a two-day ground offensive, severing a supply route from Mosul—the biggest city held by Islamic State in Iraq—to the group’s Syrian heartlands.

Maj. Murad’s assistant, Sgt. Maj. Raad Ahmed Ali, led the way with a flashlight into one of the tunnels that most impressed him. Inside, the jihadists had built a concrete bomb shelter under a house and could huddle there when airstrikes by the U.S.-led coalition threatened. The foundation of the house above the shelter had buckled after an airstrike hit close by. But the bunker was intact.

Another set of underground passageways linked a handful of houses and had its own silver ventilation-pipe system. It led to a fighting position so recently used that clean laundry was hanging on a line and a tiny cook stove had instant coffee close by, waiting to be brewed.

In one room decorated with Islamic State graffiti, the floor was covered with hundreds of used water bottles, some filled with urine. It was evidence that the radical fighters had sought to stay indoors as much as possible, even avoiding a dash outside to relieve themselves as coalition planes flew overhead.

Still, U.S. officials said the tunnels were only a minor inconvenience when the military operation against the city got under way. They were mostly small pathways allowing fighters to scurry from house to house, but likely didn’t allow them to move large equipment or materiel.

“The tunnels were a factor,” said Col. Steve Warren, a Pentagon spokesman, noting that such a system does affect surveillance, but only modestly.

Click for more from The Wall Street Journal.