The armed group is recruiting new soldiers and plotting attacks on the United States and other Western countries, US and Afghan security officials say.
ISIL is seen as an even greater threat than the Taliban because of its increasingly sophisticated military capabilities and its strategy of targeting civilians, both in Afghanistan and abroad. Concerns run so deep that some officials have come to see the Taliban, which has also clashed with ISIL, as a potential partner in containing it.
A US intelligence official based in Afghanistan told The Associated Press that a recent wave of attacks in the capital, Kabul, were "practice runs" for even bigger assaults in Europe and the US.
"This group is the most near-term threat to our homelands from Afghanistan," the official said on condition of anonymity, adding that ISIL's "core mandate" was to conduct "external attacks".
"That is their goal. It's just a matter of time," he said. "It is very scary."
ISIL appeared in Afghanistan shortly after the group's core fighters swept across Syria and Iraq in the summer of 2014, carving out a base in about one-third of both countries.
The Afghanistan affiliate refers to itself as "Khorasan Province", a name applied to parts of Afghanistan, Iran and Central Asia in the Middle Ages.
The group's presence initially numbered just a few dozen fighters, mainly Pakistan Taliban driven from their bases across the border and disgruntled Afghan Taliban attracted to ISIL's ideology.
While the Taliban have confined their struggle to Afghanistan, ISIL members there have pledged allegiance to Abu Bakr al-Baghdadi, the reclusive leader of the group in the Middle East, and embraced his call for a worldwide battle against non-Muslims.
Today, ISIL in Afghanistan numbers thousands of fighters, many from Central Asia but also from Arab countries, Chechnya, India and Bangladesh, as well as ethnic Uighurs from China.
The group has long been based in the eastern Nangarhar province, a rugged region along the border with Pakistan, but has a strong presence in northern Afghanistan. Lately, it has expanded into neighboring Kunar province, where it could prove even harder to dislodge.
The mountainous province provided shelter to Osama bin Laden for nearly a year after the Taliban was removed from power during a US-led invasion in 2001. US forces struggled for years to capture and hold high-altitude outposts there, eventually all but surrendering the region to the Taliban.
‘Today, there are thousand’
Ajmal Omar, a member of the Nangarhar provincial council, said ISIL now had a presence in four provinces - Nangarhar, Nuristan, Kunar and Laghman.
"Right now in Kunar, the right side of the road is Taliban, the left side is Daesh [ISIL], and the government is in the middle," he said, referring to the group by its Arabic acronym.
Speaking inside his heavily fortified home in the provincial capital, Jalalabad, he predicted neighboring Kunar would soon replace the Middle East as ISIL's center of gravity.
"When they began in Afghanistan they were maybe 150 Daesh, but today, there are thousands and thousands," he said.
Without an aggressive "counterterrorism" strategy, Afghanistan's ISIL affiliate will be able to carry out a large-scale attack in the US or Europe within the next year, the US intelligence official said.
"The bad news is their acquisition of key terrain, height concealment, where they can have easy access to money, weapons, equipment ... and from where they can plan, train, stage, facilitate and expedite attacks," he said.
"I think expansion of territory in eastern Afghanistan is their number one military objective."