An offshoot of the Islamic State of Iraq and the Levant (ISIL) group based near the Afghan-Pakistan border is expanding to new areas, recruiting fighters and widening the reach of attacks in the region, members of the movement and Afghan officials said.

Some members of the so-called "Khorasan Province" of ISIL, also known as ISIS, claimed responsibility for the recent attack on a Sufi shrine in Pakistan that killed 90 people, and ISIL gunmen were blamed for the deaths of six local aid workers in the north of the country, far from their stronghold in eastern Afghanistan.

Any expansion would pose a new challenge for US President Donald Trump, as he considers how many American troops to keep in Afghanistan where the main security threat remains the Taliban insurgency.

Trump has vowed to "totally destroy" the Middle East-based ISIL, yet has spoken little of Afghanistan, where US forces have been posted for 15 years.

READ MORE: The manufactured myth of ISIL in Afghanistan

Now he has not only the Taliban to consider, but also fighters swearing allegiance to ISIL, although US officials are generally less alarmed about its presence in Afghanistan than local officials.

"Daesh is not only a threat for Afghanistan but for the region and the whole world," said Shah Hussain Mortazawi, spokesman for President Ashraf Ghani's office, using a common Arabic name for the group.

The extent of direct operational links between ISIL in Afghanistan and the Middle East remains unclear, although most fighters in the "Khorasan Province" are Afghans, Pakistanis or Central Asians.

Shifting loyalties

ISIL is suspected of carrying out several attacks on minority Shia Muslim targets in Afghanistan, and the February suicide bombing at the Pakistani shrine bore some of the hallmarks of the sectarian group.

Known as the worst armed group assault in Pakistan for two years indicated that a group based in the eastern Afghan province of Nangarhar could strike deep into Pakistan territory.

"Islamic State has no proper base in Pakistan, but it has sympathizers and links in Pakistan," one member of the group told Reuters news agency, based in Afghanistan.

"Mostly the attackers and suicide bombers enter from Afghanistan to Pakistan."

READ MORE: ISIL in Afghanistan? Not so fast

Western and Afghan security officials believe fighters frequently switch allegiances between armed groups, making it difficult to know who is to blame for violence.

"Sometimes the Taliban commanders defect to Daesh and sometimes the other way around," said Mohammad Zahir Wahdat, governor of the northern Afghan province of Sar-i-Pul, where ISIL and Taliban fighters are believed to be active.

"The situation is very unclear."

The top US commander in Afghanistan, General John Nicholson, said US drone strikes and special forces operations had killed about a third of ISIL fighters in Afghanistan and cut their territory by two thirds.

US officials say intelligence suggests ISIL is based overwhelmingly in Nangarhar and neighbouring Kunar province.

They are sceptical about reports of an increased ISIL presence in the northwest, where gunmen may claim a connection to the group to boost their standing.

"Certainly if you're a local official who's looking for more resources, by saying that ISIS is in your area, you're going to get more attention," said Brigadier General Charles Cleveland, the main US military spokesman in Kabul.

Nicholson, who has asked for thousands more troops in Afghanistan, said counter-terrorism forces planned a series of operations in 2017 to defeat ISIL in Afghanistan "and preclude the migration of terrorists from Iraq and Syria into Afghanistan".

Estimating numbers is difficult. Cleveland said US officials believe the movement has only 700 fighters, but Afghan officials estimate it has around 1,500, with twice as many auxiliary helpers and up to 8,000 less active supporters.

READ MORE: Report - ISIL claims deadly attack on Pakistani forces

Those officials say fighters from Central Asian countries including Uzbekistan have come to Afghanistan, while fighters forced across the border by Pakistani military operations also gravitated towards ISIL.

A US drone strike last year killed former local ISIL leader Hafiz Saeed Khan, once a member of the Pakistani Taliban. Several Afghan security officials believe a former Afghan Taliban commander, Abdul Haseeb Logari, has replaced him.

ISIL began to be noticed in the region in early 2015, when loyalists took on the Taliban and al-Qaeda in a bid to become the leading rebel group, using tactics that stood out for their brutality.