DEH BALA, Afghanistan — Two years ago, Pentagon officials said that American forces in the remote reaches of Afghanistan could defeat the Islamic State’s offshoot here by the end of 2017.

This month, American Special Forces in eastern Afghanistan were still fighting, with no end in sight.

During a visit by a New York Times reporter to their dusty army outpost, in the eastern province of Nangarhar, the Americans pointed out the ridges and valleys at the foot of the snow-capped Spin Ghar mountains: There, they noted, was the start of the Islamic State’s territory, in some of the most forbidding terrain in Afghanistan.

The extremist group is growing, able to out-recruit its casualties so far, according to military officials. It is well funded by illicit smuggling and other revenue streams. And in the eastern part of the country, Islamic State fighters are waging a war of terrain that the United States military can — for now — only contain, those officials said.