A detained man accused of being an Islamic State fighter sits in front of newly displaced men near a check point in Qayyarah, east of Mosul, Iraq, on Oct. 26. (Goran Tomasevic/Reuters)

Islamic State militants have rounded up thousands of villagers at gunpoint to use as human shields as they retreat toward their stronghold of Mosul, the latest brutal war tactic inflicted on civilians in areas the group controls.

Military officials and some who escaped said that the vast majority of people in more than half a dozen villages were forced to walk north toward the city as the army advanced from the south, and that those who refused were shot. Some villagers said they ran and hid in the desert to avoid being captured, sleeping out in the open for days. Others said they were taken but later managed to flee.

Villagers also described mass executions of former policemen and army officers as the militants become increasingly paranoid about spies and collaborators.

The kidnappings and killings compound fears about the plight of civilians as Iraqi forces advance toward the northern city of Mosul, a prize the militants don’t appear ready to give up without a hard fight. Humanitarian organizations have said they have grave concerns that civilians are at risk of being caught in crossfire, trapped between fighting or used as human shields.

Holding civilian populations hostage is among the tactics the militants use to waylay advancing forces and complicate the U.S.-led airstrikes that support them. They also have set fire to oil wells and a sulfur plant south of the city, sending noxious fumes over hundreds of miles.

The complex military battle to retake Mosul from the Islamic State has begun. Here is what you need to know about the ancient Iraqi city. (Ishaan Tharoor, Kareem Fahim, Jason Aldag/The Washington Post)

Before launching the offensive for Mosul last week, Iraqi officials estimated that as many as 1.8 million residents were still in the city, with expectations of an exodus as forces advanced. But residents of Tulul al-Nasir, a gray, cinder-block settlement about 25 miles south of the city, said they were forced to flee the other way.

“They told us on the loudspeakers that whoever stays will be killed,” said Mohammed Ali, 45. They were ordered by the militants to walk about 15 miles north to Hamam al-Ali, a larger village that is still under Islamic State control.

As he spoke, men crowded around him to list their family members who are missing. Some said dozens had been taken, with families divided in the confusion.

More than 90 percent of the village’s 5,000 residents were kidnapped, said Iraqi army Col. Faisal Ali Abdellatif.

“When they retreat from every village, they take the civilians with them to use as human shields,” he said.

At her house in Tulul al-Nasir, Bushra Hussein recalled how two armed militants came by one recent day.

“They said we had to gather on the road and that if they came back in 30 minutes and found us here, they’d kill us,” she said.

With thousands of her neighbors, she was marched north, pushing her disabled 26-year-old son in his wheelchair, which broke after several days. Unable to move him, she was allowed to stay by the side of the road with him, where she remained until security forces advanced. Her husband, three other sons, three daughters and grandchildren were all forced to move on with the militants, she said. They called her briefly two days earlier to say they were in Mosul.

“Thousands of families have been taken,” she said. “No one wanted to go.”

For those who refused to leave, the punishment was swift.

On the outskirts of the village, Moyad Atallah, 40, was attending a funeral for his three brothers, who were shot after protesting. Eight Islamic State fighters in pickup trucks mounted with machine guns had arrived at their house at sundown to round them up, he said. One brother refused.

“They shot him just there,” said Atallah, pointing at the dust outside his home. When his two other brothers then fought back, they were also killed, he said. The militants took their money and the family car, then kidnapped another brother and said they would return. The rest of the family fled and hid in an abandoned house nearby, including 11 now-orphaned children.

The Islamic State’s utter disregard for the safety of civilians and its apparently deliberate use of human shields is putting people trapped in areas of active conflict at even greater risk as Iraqi forces advance, said Lynn Maalouf, a Beirut-based researcher for Amnesty International.

Iraqi security forces have slowly won back villages and towns outside Mosul, but the militants have shown little sign that they will give up ground easily, and Iraqi and U.S. military officials say they expect the fight to get tougher as they near the city’s outskirts.

As the militants are gradually squeezed, they have stepped up their savagery against local populations, residents have said.

Abdulrahim al-Shammiri, the chairman of the human rights committee in the Iraqi parliament, said that 190 civilians were executed in Hamam al-Ali on Wednesday after being “kidnapped” from surrounding areas.

Those who escaped said that former police or army officers were separated from their families and executed.

“They killed 20 people in front of me,” said one 19-year-old from the village of Safina, who was held for three days in Hamam al-Ali before his family escaped at night, walking for days before reaching the Iraqi security forces.

The family members were separated during their escape, and militants on motorbikes recaptured some of them while others watched from a ditch. Those who escaped were shot at as they fled; one woman was hit in the abdomen and is receiving treatment in Irbil. The family members declined to give their names because of concerns about the security of 30 relatives who are still missing.

“All of us were against them, but they dragged us with them, all the village,” said his aunt, whose husband, four sons and three daughters are missing.

Mustafa Salim contributed to this report.