MOHMAND VALLEY, Afghanistan—U.S. forces are preparing for a battle with Islamic State over a valley that was once the Afghan hub of the group’s campaign to create a world-wide caliphate.

The militants have been probing American and Afghan positions and hiding weapons caches in the ridges overlooking Mohmand Valley, which was controlled by ISIS fighters until allied troops chased them into the Spingar mountains at the end of last year.

That operation allowed civilians who had fled Islamic State to return to their stone-terraced farms. Now many families are reversing course in anticipation of an attempt by insurgents to retake the ground.

“The civilians are leaving the valley,” a U.S. Green Beret told troops who arrived this month to help defend an American outpost in the valley. “So those guys are going to be coming out of the mountains anytime now.”

The Americans aren’t waiting for Islamic State to take the initiative: U.S. troops patrol the mountains, looking to take out fighters and caches to weaken the enemy and mute their expected offensive.