The woman said that her husband was an Islamic State fighter but that she left him after trying, in vain, to persuade him to defect. Last week, she took their six children and fled across the battle lines toward ground controlled by the Iraqi army, she said.

But as the woman spoke in a camp for newly displaced people south of Mosul — watched by men with guns, with no electricity or food in her tent and her children playing in dirt — her escape seemed like the prelude to another miserable ordeal.

The camp sat next to her village, but she was not allowed to go home, pending an interrogation by Iraqi officials into her past and the activities of her husband, whom she claimed not to have seen in months. Even if she were eventually granted permission to leave, it was not clear there would be a place for her in the village — or, for that matter, in Iraq.

Thousands of people who lived for the past two years under the rule of the militants have begun to escape their villages as a huge Iraqi force closes in on the northern city of Mosul, free now to tell their stories of brutality and privation and near-death escapes.

Most, though, are Sunni Muslims, unable to celebrate just yet as they face questions from the authorities and the country at large about their years living alongside the Sunni militants — and about any ties to the jihadists, whether real or just perceived.

Aid organizations are warning of a humanitarian disaster for refugees fleeing the fighting in Mosul, as Iraqi forces begin their offensive against Islamic State. (Reuters)

Their treatment by the Shiite-led government in the current campaign is seen as crucial to rebuilding Sunni trust in the state, which plummeted so low two years ago that some Sunnis welcomed the militants to their towns, cities and villages.

[Hundreds of thousands may flee Mosul]

In other areas captured from the Islamic State, though, men and boys have sometimes faced months of screening, with human rights groups also reporting incidents of execution, torture and arbitrary arrest by the country’s array of militias and security forces.

Those with family members who joined the Islamic State, such as the woman, who gave only her first name, Khowla, face a different kind of reckoning. Often, they are barred from returning to their villages by local officials, tribal authorities or vengeful neighbors. Khowla insisted it would be different for her, saying that her hometown neighbors had welcomed her after her escape from a village farther north in Islamic State territory, where she had been living with her husband.

“The whole village received me. They all like me. They cried for me,” she said. But another family had moved into her home. And she had already started to brace herself for the recriminations she would face because of her husband’s affiliation with the Islamic State.

“It wasn’t my fault,” she said, as night fell on the camp and one of her children began to wail. “I’m not guilty. Why should we be displaced?”

Millions of people have been uprooted over the past two years by the Islamic State’s expansion and by the military operations to defeat the group — a mass displacement that has recalled Iraq’s recent painful eras, including the U.S.-led invasion and the bloody civil war that followed.

Each era has been scarred, too, by social upheaval, revenge killings or forced displacements that over years have fractured and reshaped the country.

[Why the liberation of Mosul could come at a high cost]

Iraqi officials have taken measures that some hope will limit the potentially violent aftermath of the Mosul campaign — for instance, by limiting the kinds of forces that will enter the city and excluding sectarian militias. They have said they are trying to streamline the screening process and are urging civilians to stay in their homes.

There is also a sense that the widespread revulsion with the militants — even by disaffected Sunnis long marginalized by the central government — may have created an opportunity for a more durable moment of national unity.

But they are all just hopes, and perhaps not enough to stave off some people’s desire for retribution.

A few tents away in the same camp where Khowla stayed with her children, a group of shepherds said they had been beaten by soldiers after they escaped from the Islamic State. But they had not been held for long, said one, who had a welt over his eye.

In another tent, a 40-year-old driver named Ali, who fled his village late last week, said some sort of violent reckoning was inevitable. “In the beginning, there will be revenge. But then it will be better,” he said.

Like most of those who had fled the militants, he easily recalled the catalogue of atrocities he had witnessed over the past two years. Five relatives — who were police officers, soldiers or guards protecting oil facilities — had been executed by the militants, he said. His village, with just 20 families, had been treated harshly, he said, because it had developed a reputation for resistance to the Islamic State.

When the militants first came to the village, “we were all deceived by their appearance,” he said. “We thought they were Muslims.” As they meted out punishments for petty crimes and extorted residents, “we realized they had nothing to do with Islam,” he added.

In another camp, east of Mosul, dozens of young men who had fled areas in and around the city were kept behind a padlocked gate, sequestered from families who moved freely in other parts of the camp. Some had been there for 40 days without any indication of when they would be allowed to leave, they said.

“We fled a prison for another prison,” said Mohamed Asad, who sat with a group of young men in a tent.

Their escapes had been harrowing. One young man, Hassan Mohamed, 22, said he left Mosul about 10 days earlier. He sold cigarettes on the black market, had been arrested by the militants several times, and was finally sent away by his family, who were worried that his luck would run out, he said.

To leave, he paid a smuggler $400, crossed a river in an inflatable dinghy and walked for eight hours, skirting a front line of the battlefield at night, he said.

He had no idea when he would be reunited with his family, who remained in the city, or when he would leave the camp, with Mosul occupied for perhaps weeks or months to come.

In another part of the camp, a group of men who fled villages south of the city focused less on what would follow the military operations, enjoying for the moment pleasures they had recently gained. Cigarettes, banned by the militants, seemed to be first on the list.

“We came here hungry and just keep smoking,” said Khalid Khalil, as a pack was passed around where they sat in the courtyard of a mosque.

Khalil and the others insisted there had been no way to resist the 30 or so Islamic State members who occupied their village. While keeping a close watch on residents, the militants prepared for any attack, digging tunnels and stockpiling weapons.

Everyone wanted to flee. “What did Daesh provide us?” said Asad Hassan, another resident of the village, using an Arabic acronym for the Islamic State. “I had sons who were state employees. They didn’t give them jobs. Students didn’t go back to school.”

After escaping the village, they had been treated well by Kurdish soldiers known as peshmerga, who had brought them to the camp. Now, he and his fellow villagers were waiting for better treatment from the government to solve the kind of long-term problems that provided an opening for the Islamic State in the first place.

“It is up to the state,” he said.

Aaso Ameen Shwan in Imam Gharbi and Loveday Morris in Irbil contributed to this report.

Read more:

Islamic State sets sulfur alight in attempt to foil attack on militant stronghold

The history of Mosul, in five maps

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news