ISIS insurgents in Afghanistan prove resilient against US Special Forces ABC News got exclusive access to the Green Berets in the fight against ISIS.

NANGARHAR PROVINCE, Afghanistan -- ABC News has been given exclusive access to U.S. Special Forces troops fighting on the frontlines against ISIS in Afghanistan.

The small, elite unit of Green Berets is working alongside Afghan commandos to try to root out the insurgents from Nangarhar Province near the border with Pakistan.

The conflict in Afghanistan is America’s longest war and despite successes, the insurgents have proven remarkably resilient, not least because of the sanctuary and support they receive from neighboring countries.

Gen. John Nicholson, the commander of U.S. and other foreign forces in Afghanistan, says troops are fighting ISIS in Afghanistan so America does not have to face further terrorist attacks at home.

Unlike the Taliban, which is primarily a homegrown group of hardline religious nationalists, ISIS is a relatively new and somewhat alien presence in Afghanistan. American military commanders say it is bolstered by jihadis from Pakistan, Chechnya, Uzbekistan and India.

Nicholson admits that an insurgency that receives support from a neighboring country -- not to mention sanctuary -- is almost impossible to defeat.

Two U.S. service members were killed last week in separate "insider attacks."

The terrain is tough and demanding with steep jagged snow-capped mountains and plunging valleys. ISIS insurgents have riddled the roads and homes with improvised explosive devises and launched attacks on American forces, but they appear to be on the retreat.

A handful of districts have been wrested from insurgent control, and the Special Forces troops are helping local forces reestablish a presence, building checkpoints and outposts on key terrain.

But the challenge, as it has always been in Afghanistan, will be how to hold onto the territory it has taken.

The overwhelming firepower at America’s disposal means it can easily drive out insurgent groups. But from Helmand to Kandahar, history shows it is less capable of keeping it in government hands, not least because of the weakness and sometimes corruption and incompetence of local partner forces.

America’s military leaders believe Afghanistan is now changing, with a new generation of well-trained, experienced and competent Afghan forces.

But it is telling that almost no one talks of military victory these days. From Nicholson on down, there is now a consensus that only a political process will achieve an end to the fighting.