Kabul, Afghanistan - Mohammed Sharif sits in a tiny visitor's room inside a prison run by Afghanistan's intelligence agency, the National Directorate of Security [NDS], in the capital Kabul.

A member of the Islamic State of the Khorasan Province (ISKP), an ISIL (ISIS) affiliate, Sharif, 21, spent the last eight months in prison after he was captured during a raid in Kabul.

More:

Last December, Afghan and US forces claimed to have meted out a humiliating defeat to ISKP in Nangarhar, its main stronghold in the war-torn country.

ISIL claims deadly attacks in Kabul

But in the past weeks, the group resurfaced again claiming responsibility for the killing of more than 50 people in two attacks targeting the minority Shia and Sikh communities in the Afghan capital.

This has raised concerns in the country's security establishment at the group's capability to carry out daring attacks in the capital, as the West-backed Kabul government prepared to hold talks with the Taliban as part of a United States-brokered peace process.

The US and the Taliban signed an agreement on February 29 in Qatar's capital, Doha, aimed at ending the 18-year war, with a gradual withdrawal of foreign troops from the country.

ISKP's attacks has raised concerns in the country's security establishment at the group's capability to carry out daring attacks in the capital [Maciej Stanik/Al Jazeera]

"Extremist groups around the world often refocus their efforts into acts of terror, when faced with military setbacks," said Andrew Watkins, senior Afghanistan analyst with the International Crisis Group.

"ISKP's recent resurgence of activity in Kabul reveals a return to one of the group's primary target sets - ethnic and religious minorities - that suggest a continuity in the group's objectives from years prior: Attempting to foment sectarian divide and conflict."

Sharif says he joined the ISKP to take revenge against the Americans who since the 2001 invasion of the South Asian country have committed numerous atrocities against civilians.

But he also emphasised the hatred towards the "infidels" - the local communities who are not Sunni Muslims.

"The Hazaras [Afghanistan's largest ethnic minorities, who are primarily Shia Muslims] insult us, they don't accept Caliph Umar and Bibi Aisha [figures important in Sunni Islam] and tell awful things about them. This is the main reason why the Islamic State [ISKP] is killing the Hazaras," Sharif said.

"As a Muslim, I was outraged when Americans were shooting the Quran in Bagram. In France, the Quran was burned many times. This is our right to fight against these people. From the very first day, I wanted to kill the Americans and the infidels," he told Al Jazeera.

Sharif grew up in Kabul, as one of seven siblings to poor parents. He describes his childhood as "disappointing", as he began to work on the streets of Kabul, selling plastic from the age of four.

He was encouraged to join ISKP by his older brother, who was killed in a drone attack in 2019 carried out by the US.

Origin of ISKP in Afghanistan

After joining the ISKP, which he said was an easy process, he was asked to "transport explosives for suicide bombers on motorcycles and planting them in different places [within Kabul]".

"We were not responsible for big attacks," he told Al Jazeera.

Each ISKP cell in the capital city, he says, had about 10 members and focused on different tasks. He does not know how many of them operated in Kabul as there was limited contact between the cells.

Sharif said the armed group faced a setback in 2019, when its main recruiting leader, Najibullah, was killed in a drone attack in Nangarhar.

ISKP's activity in Afghanistan began in 2015 following the Pakistani operation against armed groups in North Waziristan, close to the Afghan border, which displaced more than one million people.

Islamabad crushed armed groups in 2014. Many of the former fighters, including the members of Tehrik-i-Taliban in Pakistan (TTP), found refuge across the border in Afghanistan.

As Andrew Watkins, the analyst from the International Crisis Group explains, there has long been a sense of affinity between the communities in the porous Afghan-Pakistani borderland.

While, according to Watkins, it is hard to establish how many of the original TTP members turned to ISKP, it is clear that most of its leadership was of Pakistani origin.

Local Afghans, including former Taliban fighters, flocked to the group, as well as Chechens, Central Asians, Arabs and Uighurs.

Black flags soon appeared in several districts in the mountainous Nangarhar province bordering Pakistan, spreading fear among local communities.

On the one hand, the ISKP gained military control over a certain geographic area, on the other, their members organised numerous attacks in urban centres, mostly against the Hazaras Shia community.

According to Watkins, there is little evidence that the group's operations were coordinated with ISIL's core in the Middle East.

Over time, Watkins says, the ISKP also showed little desire to engage in state-building or providing services, although it managed to take control over the smuggling industry.

ISIL's brutality

As Global Witness reported in 2018, it made millions of dollars exporting talc, chromite and marble across the Pakistani border.

The recent UN report in 2019 claims that the ISKP had between 2,500 and 4,000 fighters in Afghanistan.

Watkins, however, is sceptical about any such estimates as there are discrepancies in numbers from other sources.

The picturesque village of Garbawa in Nangarhar province experienced the brutality of the ISKP early on when the region fell under the group's control in 2017.

Local elders told Al Jazeera that even Soviet atrocities fade in comparison to ISKP's brutality. When they told their stories sitting under the trees in the village's centre, the children standing around could not stem their tears.

"Over a hundred of our people were killed by the ISKP. It was like a slaughterhouse," Amrullah, 65, told Al Jazeera.

"Once they kidnapped an eight-year-old boy. The next day they asked the village men to go to the riverside to get him. When we got there, we found the boy's head floating in the river.

The villagers initially fought back but ISKP's brutality gave them no choice but to leave. Most of them settled in a refugee camp in Jalalabad, Nangarhar's capital.

The village of Garbawa in Nangarhar province experienced the brutality of the ISKP when the region fell under the group's control in 2017 [Maciej Stanik/Al Jazeera]

They only returned after the Taliban, the main armed group in the country, pushed the group out of the village several months ago.

Today, with no government presence, the only force protecting the village is the villagers themselves. They raised money and bought weapons for their "police" to protect the villagers.

"Our livestock was killed. The only work we have here is farming. We still haven't recovered from that incident. The ISKP was here only to spread terror," Gulab Khan, another village elder, said.

'Inflict major casualties'

Anas, 22, from Kot district in Nangarhar says he decided to join the ISKP after spending two years in Bagram prison between 2017/19. He initially joined the TTP when the group took over his village. He is now in the same NDS run prison in Kabul, awaiting trial.

Anas, together with several other men, surrendered themselves to the NDS, in December 2019, when their bases in Nangarhar province fell to government forces.

"Jails in Afghanistan are the main recruitment ground for the ISKP. I was appalled with the prison conditions," Anas says.

He joined the ISKP after talking to a local mullah (a religious leader), who encouraged him to fight against the US and "infidels".

Shah Mahmood Miakhel, Nangarhar's governor, says the ISKP was not a significant military force. However, they managed to destabilise the province for five years, mostly because of Kabul's lack of vision and adequate strategy to fight back.

"I can say it is a leadership issue, you cannot find solutions to our problems in Kabul. For local problems you need local solutions. Of course with their support," he told Al Jazeera sitting in his office's yard in Jalalabad.

"Our strategy was to cut off their supply route to Orakzai [Pakistan]. It took us two months. All the operations happened over the last year, we cleared the area, we established bases, and then began to improve governance."

With no government presence , the only force protecting the village is the villagers themselves [Maciej Stanik/Al Jazeera]

But according to Watkins, while the ISKP has indeed faced defeat in Nangarhar, some of its forces managed to escape to the Kunar province or across the border to Pakistan.

The recent attacks by the ISKP in Kabul, it seems, are an attempt to show that although their military capacity weakened, they can still inflict major casualties in urban centres.

Most importantly, however, even if the ISKP never rebuilds itself, it was the grim situation in the Afghan-Pakistani borderland that provided a fertile ground for the group's development.

A problem, which has not been addressed to this day.

"On both sides of the border these communities have been marginalised. Not only by their governments, but on the Afghan side even by the Taliban," Watkins says.

"That is why there was space for the Islamic State (ISKP) to come in."