Then, in groups of two or three, they emerge from the night: men, women, children, the elderly.
Some can barely walk. They've been on their feet for hours, and need to be carried the rest of the way.
It's the same routine, night after night.
To get to the Kurdish front lines
in northern Iraq, people fleeing Mosul must avoid detection by ISIS militants, step carefully through minefields, and be ready to find shelter if mortar rounds come crashing down. For men, capture by ISIS could mean punishment if they're lucky -- but more likely it will mean death.
By the time they reach safety, some have been walking for four or five hours. Adults must carry the young children. They arrive thirsty, hungry and exhausted. Walking by night, however, is preferable to doing it by day, when they can be picked off by ISIS snipers or fall prey to the withering heat, with daytime temperatures well over 110 degrees Fahrenheit (around 45 degrees Celsius).
It's risky, but it's worth it, says a man who declined to identify himself but who says he worked as a nurse.
"I came because of the tyranny of Daesh," he says, using an Arabic acronym for ISIS. "I came because of the lack of food and water, because of the lack of security. ISIS are gangs of killers and thieves. The most basic necessities of life no longer exist. There is no electricity, no water, no connection with the outside world."
The threat of execution by ISIS, for offenses large and small, looms over everyone, he said. "They kill you if you don't fast. They kill you if you don't pray. They kill women if they show their faces. They have no other way of doing things than killing. The only punishment is killing: no prison, no fines, just killing, killing and killing."
The number of people fleeing Mosul and surrounding towns and villages has been rising steadily in recent weeks, as Iraqi government and Kurdish forces slowly retake territory around the city
. At the same time the U.S.-led coalition is ratcheting up pressure, its planes targeting ISIS. The U.S. also announced it is sending more than 500 additional troops
to support the battle to liberate Mosul.
Before ISIS drove Iraqi forces from Mosul in June 2014, the city had a population of around two-and-a-half million people. Hundreds of thousands fled when the extremists took over, and hundreds of thousands more are expected to pour out of the city when the battle for Mosul begins in earnest.
The Kurdish soldiers -- known as Peshmerga -- welcome those who make it to their lines, but are nervous. They can never be sure if the men approaching them are genuinely fleeing to safety or are ISIS militants armed with explosive vests or weapons.
Every man who approaches is ordered to strip down to his underwear and get down on his knees. Some soldiers keep their weapons aimed on these men as others approach them cautiously, asking questions. Others search their possessions, looking for identification and checking cell phones for messages or images that might hint at ISIS sympathies.
Once they've been cleared, the refugees are herded into trucks and moved to a nearby base. There they rest, the children sleep, and the adults talk of the life they left behind.
"The women all had to wear black and be completely covered up," recalls one woman. "The men had to grow their beards long. It was hard. There was no work, and there was nothing in the stores to buy. It was really bad."
Eventually these people will be moved to one of the many camps set up around northern Iraq for those who had fled ISIS. The lucky ones might be able to rent apartments in cities like Baghdad or Irbil or Kirkuk.
When they will actually be able to go home is anyone's guess. Iraqi officials confidently predict ISIS will be driven from Mosul by the end of the year. That's plausible, but what is far less clear is how much of Mosul will actually survive the battle. The people fleeing Mosul now may have nothing to go back to.