NEAR BAGHOUZ, Syria — Hundreds of people have trudged out of the Islamic State’s last stronghold since Tuesday, surrendering to U.S.-backed forces before their final assault to capture the only village still in the militants’ hands.

Some of the Islamic State’s most die-hard fighters are pinned down in Baghouz, a remote hamlet nestled on a bend of the Euphrates River close to the Iraqi border. There is only one path out of what they once called the caliphate, snaking through the green grass and flowers of eastern Syria. No longer spanning an area the size of Britain, their territory is now visible in its entirety from hills that surround it, covering no more than a square mile.

After three days of fighting, the combat quieted — with a lull in artillery fire and U.S. airstrikes — as the U.S.-supported Syrian Democratic Forces gave the village’s remaining inhabitants a chance to flee or give themselves up.

More than 1,200 people had accepted the offer since Tuesday, American aid workers said, walking miles in the darkness toward the SDF militia fighters on the other side of a hill — and on to an uncertain future. Among those departing the village were defeated foot soldiers of the Islamic State.

“Last night looked like a major break,” said Dave Eubank of the Free Burma Rangers, a Christian group that specializes in delivering aid in war zones. “To have more than a thousand walking over pretty much at once, someone had to open the door.”

More than 38,000 people have left the Islamic State’s shrinking territory in eastern Syria since the start of the year, monitoring groups say, but several thousand remain inside Baghouz, packed into tunnels under the village. Some of the most battle-hardened are still believed to be inside, using civilians as human shields and determined to fight to the death.

At its height, the Islamic State’s self-proclaimed caliphate had been home to some 40,000 foreign fighters from 110 countries, according to the Soufan Center, a New York-based research group focusing on strategic threats. Almost five years after the militant group’s lightning sweep across parts of Iraq and Syria, the Islamic State is surrounded on all sides and the SDF expects to declare victory within days. At a nearby base, the SDF has built a stage for the anticipated victory announcement.

The SDF and humanitarian groups monitoring the situation say that nearly all of Baghouz’s remaining inhabitants have some link to the Islamic State, in many cases as wives and children of fighters. Among them are foreigners who had come to support or fight for the Islamic State. Canadians, Britons and Sudanese nationals are among those who have left in recent days.

Suspected Islamic State members who reach the SDF position are taken away for questioning.

One group that walked across the horizon and up to the rocky outpost mostly comprised men, looking tired though largely unburdened by the hardships of sickness and hunger that other escapees had endured. Two of the men, like others, had wrapped themselves in blankets but appeared to be in fine health.

They were driven away in a flatbed truck, apparently for further interrogation at a U.S. military site several miles away.

Women and minors are considered civilians under international law and, after being screened, are transferred to displacement camps across Syria’s northeast.

At the screening point overlooking Baghouz, women stood in lines before the SDF fighters. The women raised their hands as their bodies were scanned with metal detectors. Last week, a man had tried to smuggle out a hand grenade, fighters said, tucking it under his shirt as he approached the screening point.

Families interviewed Wednesday described a journey in recent months beset by sickness and hunger. None were originally from Baghouz, and all denied any connection to Islamic State fighters. Several said they were Iraqi, although their accents appeared to suggest otherwise.

“It was God’s will that we ended up there,” said one woman who gave her name as Om Mohamed. “We had no control over his wishes. It was out of our hands.”

Stepping out of the screening line, she shouted at the SDF fighters scanning the group one by one: “We’ve been here for hours and you haven’t even given us food!”

At nearly every screening point, the number of children was striking. They were sunburned and barefoot, and it looked as if they were wrapped in as many layers as their parents could manage. Several infants showed signs of malnutrition, crying and straining as their skin stretched tightly across cheekbones and limbs. Many were wounded.

In one circle, an infant lay on her mother’s lap, sucking hungrily on a bottle empty but for a layer of congealed milk inside. Another boy coughed as he tried to swallow what appeared to be flour.

Aid workers from the Free Burma Rangers said Wednesday that they had treated two children with gunshot wounds to the head, apparently from Islamic State snipers trying to prevent people from leaving. One was 6 years old, the other 3.

Civilians have also reached the outpost with phone numbers of militants willing to surrender, several SDF fighters said.

The elimination of the cali­phate will raise new questions about how the Islamic State might regroup across the troubled and often lawless stretches of Syria and Iraq.

But for now, with the SDF expecting the military operation to end within days, the militiamen were getting ready to savor a victory.

“Their state is in its final stages here today,” said Adnan Afrin, an SDF commander for the operation. “We’re talking about hundreds of square meters — that’s it. Await the coming days.”

Mohamed Shikh Ibrahim contributed to this report.