Afghan farmer Gulnar Malik had seen her share of hardships as war ravaged her country for decades -- but nothing prepared the mother of five for the arrival of the Islamic State group.

IS militants seized her village in the east Afghanistan province of Nangarhar, bordering Pakistan, nearly five years ago, unleashing a tide of carnage and slaughter as they sought to expand their self-declared Syria and Iraq "caliphate" into Afghanistan.

The IS "fighters committed a lot of atrocities", Malik, 55, told AFP shortly after the Afghan army dislodged the jihadists from her home district of Achin, following weeks of house-to-house fighting, shelling and US air strikes.

Fighters from the Islamic State group unleashed a wave of destruction in the areas they seized in eastern Afghanistan
Fighters from the Islamic State group unleashed a wave of destruction in the areas they seized in eastern Afghanistan AFP / NOORULLAH SHIRZADA

"They shot dead one of my children and injured another. My dead boy was trying to run away when they shot him," she recalled, adding that her husband had been detained and tortured over a three-week period.

Malik went home last month having spent years in the comparative safety of a nearby town, after Afghan military officials announced that IS's Afghan branch, also known as IS in the Khorasan, or IS-K, had been completely defeated in Nangarhar.

While some local officials are not convinced that the loss is comprehensive, the Nangarhar gains -- if they hold -- would mark a major accomplishment for Afghanistan's beleaguered security forces.

If the Nangarhar gains hold, they would mark a major accomplishment for Afghanistan's beleaguered security forces
If the Nangarhar gains hold, they would mark a major accomplishment for Afghanistan's beleaguered security forces AFP / NOORULLAH SHIRZADA

The exact nature of links between IS in Afghanistan and the Middle East remains unclear, but IS-K first emerged in the region in 2014, largely made up of disaffected fighters from the Taliban and other jihadist groups in Afghanistan, Pakistan and Central Asia.

IS-K fighters coalesced in the hilly district of Achin in Nangarhar in 2015, the first time they controlled territory inside Afghanistan.

They confounded early US predictions they would be defeated quickly, withstanding continual air strikes, as well as battles with the rival Taliban.

IS jihadists were dislodged from Achin after weeks of house-to-house fighting, shelling and Us air strikes
IS jihadists were dislodged from Achin after weeks of house-to-house fighting, shelling and Us air strikes AFP / NOORULLAH SHIRZADA

They replenished their ranks using a mix of cash and extreme ideology spread inside Kabul's universities.

An AFP correspondent recently travelled with an Afghan army unit to a small village in Achin and saw the destruction wrought by IS-K.

Built on a forested hillside, many stonework buildings had been reduced to rubble, house walls were pockmarked with bullet holes and there were mangled remains of cars on the roadside.

Despite gains against the Islamic State group in Nangarhar, it will take time for residents to feel safe
Despite gains against the Islamic State group in Nangarhar, it will take time for residents to feel safe AFP / NOORULLAH SHIRZADA

"We were forced to leave our homes. Now we have returned, all our houses and all of our belongings are destroyed," said local resident Himatullah, 36, who only uses one name.

He recalled that when IS-K fighters first arrived, they forced residents to sit on bombs, then detonated them.

Another day, they beheaded a man accused of infidelity.

Even though the village now is free of IS-K, it will take time for residents to feel safe, and many are traumatised.

While IS has been defeated in Nangarhar, one US official said there remain pockets with the ability to carry out attacks
While IS has been defeated in Nangarhar, one US official said there remain pockets with the ability to carry out attacks AFP / NOORULLAH SHIRZADA

"Daesh have planted mines everywhere -- in schools, clinics, people's homes," Himatullah said, using the Arabic acronym for IS.

According to an American defence official, Afghan military operations supported by US-led coalition air strikes set the conditions that have in recent weeks forced more than 1,400 IS fighters and their families to surrender.

Stalled talks between the US and the Taliban were aimed at striking a deal that would have seen the Pentagon pull thousands of troops from Afghanistan in return for various security guarantees, while leaving a counter-terrorism footprint in the country to go after IS-K and other jihadist groups.

In the years since 2015, IS-K proved resilient and resourceful, using tunnels to shelter from an aerial onslaught that famously included the US deploying an immense weapon dubbed the "Mother Of All Bombs" in 2017.

US military officials no longer detail IS-K's force strength, but for years it was estimated between 2,500 and 4,000 fighters.

"We measure (the) Daesh threat in terms of intentions, capabilities and trajectory, not in numbers," the defence official told AFP.

The official noted that while IS-K has been defeated in Nangarhar, pockets with the ability to carry out devastating attacks remain, and scattered elements will attempt to regroup.

"Bottom line, Daesh remains a threat -- they have the will and intent to export terror outside Afghanistan," the official added.

Herat Khan, an Achin tribal elder, said only about 10 percent of families stayed in the district during IS-K's occupation.

The government should "help us in reconstructing schools, houses, clinics and mosques," Khan said, noting that perhaps thousands of homes had been reduced to rubble.

He said the jihadists remained in two places in Achin, but Afghan army Commander Najibullah said IS-K had been wiped out.

"The whole area has been cleaned of their fighters," he said.

"They will not make a comeback and the residents of the area, the returnees, should continue their normal lives".

Still, IS-K remains in Afghanistan, notably in Kunar province, which neighbours Nangarhar, as well as in the capital Kabul.