ISIS's capital in Afghanistan has been captured after a joint US-Afghan assault that left nearly 170 terrorists dead.

The operation in Deh Bala, on the border with Pakistan, began at the end of April and was largely complete in early June.

About 600 American Green Berets and three Afghan commando companies were involved, according to Military.com, with no casualties for the allies.

'This was one of the main green zones that did two things. One, it provided money, finance, logistics to ISIS and we've taken that away from them,' Lt. Col. Josh Thiel, from the U.S. First Special Forces Group, said.

About 600 American Green Berets and three Afghan commando companies were involved, according to Military.com, with no casualties for the allies. Pictured: An American flag over the base

The operation in Deh Bala, on the border with Pakistan, began at the end of April and was largely complete in early June.

'Additionally, ISIS was using this as a site to prepare and move high-profile attacks on Kabul and Jalalabad.'

Officials said soldiers found booby traps and the bodies of two beheaded women as they cleared the area of terrorists.

The operation, involving three companies of Afghan commandos supported by U.S. air strikes and American Special Forces teams, began with troops arriving by helicopter and setting up an operations base near the village of Gargari, where the ISIS fighters were trying to establish a local capital.

Several days of heavy fighting ended in early June with 167 Islamic State fighters killed and large quantities of equipment captured.

The fight against ISIS and other militant groups including Al Qaeda is at the heart of the U.S. counterterrorism mission being conducted alongside the NATO-led Resolute Support operation that trains and advises Afghan security forces.

Intended to prevent Afghanistan being used as a base for future attacks against the United States, it is in large part fought against irregular forces in remote valleys on the far eastern edge of the country, an area crisscrossed by smuggling routes into the tribal areas of Pakistan.

Militants loyal to Islamic State Khorasan Province (ISKP), the movement's local affiliate, first started appearing in Nangarhar around four years ago.

Since then, the movement has gained a reputation for brutality extreme even by the standards of the Afghan conflict, making a trademark of executions by beheading or explosion.

Afghan village elders sit at an Afghan and U.S. Special Forces base in Deh Bala district, Nangarhar province, Afghanistan on July 7

The fighters in Deh Bala, next to Achin district where the U.S. military dropped its largest non-nuclear bomb last year, were funding themselves by illegal logging and talc mining, as well as exploiting local villagers.

However, a clear link between fighters in places like Gargari, a mudbrick village down the road from Deh Bala's district capital, and the militants behind a series of sophisticated suicide attacks in Kabul or Jalalabad is elusive.

'The network is very fungible...,' said Brigadier General John Brennan, Resolute Support commander in eastern Afghanistan.

'I wouldn't say the actual suicide bombers came from Deh Bala, but facilitation runs all along the border and part of it used to come through here.'