These fighters, who have received public praise from Iran's supreme leader Ayatollah Ali Khamenei, even have their own brigades, but counterterrorism officials in both countries worry about the mayhem they might cause when they return home to countries already wrestling with a major militant problem.
Amir Toumaj, Iran research analyst at the US-based Foundation for the Defense of Democracies, said the number of fighters is fluid but as many as 6,000 Afghans are fighting for Assad, while the number of Pakistanis, who fight under the banner of the Zainabayoun Brigade, is in the hundreds.
"People were expecting blowback," said Toumaj. IS "itself has its own strategy to inflame sectarian strife."
Shiites in Afghanistan are frightened. Worshippers at a recent Friday prayer service said Shiite mosques in the Afghan capital, including the largest, Ibrahim Khalil mosque, were barely a third full. Previously on Fridays, the Islamic holy day, the faithful were so many that the overflow often spilled out on the street outside the mosque.
More From This Section
Pakistan has also been targeted by the IS in Khorasan province. IS has claimed several brutal attacks on the country's Shiite community, sending suicide bombers to shrines they frequent, killing scores of devotees.
In Pakistan, sectarian rivalries routinely erupt in violence. The usual targets are the country's minority Shiites, making them willing recruits, said Toumaj. The most fertile recruitment ground for Iran has been Parachinar, the regional capital of the Khurram tribal region, that borders Afghanistan, he said. There, Shiites have been targeted by suicide bombings carried out by Sunni militants, who revile Shiites as heretics.