For more than a decade, a hard-line Central Asian militant group wreaked havoc across northwestern Pakistan before being pushed out of the country last June.
Nearly a year later, thousands of fighters from the Islamic Movement of Uzbekistan (IMU) are now at the forefront of conflicts in at least eight provinces in neighboring Afghanistan as violence escalates during the traditional spring fighting season.
Author Ahmed Rashid has followed the IMU since its emergence in the 1990s. He says the current escalation in northern Afghanistan is prompted by IMU efforts to rebuild secure bases before an expected peace deal between the Taliban and the Afghan government.
"They would like to rebuild their sanctuaries in Tajikistan and Uzbekistan," he told RFE/RL's Gandhara website. "[They are trying] to build bases and areas of control in northern Afghanistan, which could lead to the same across the border in Uzbekistan, Tajikistan, Turkmenistan and Kyrgyzstan."
Afghan Forces fighting against militants in Kunduz
Since last fall, Afghan officials and observers see the IMU as behind fierce battles and increased violence in Zabul, Baghlan, Kunduz, Badakhshan, Takhar, Faryab, Jowzjan and Badghis provinces. The latter six border Tajikistan, Uzbekistan and Turkmenistan.
In Kunduz alone, scores of civilians, soldiers and militants have been killed in pitched battles beginning last month. The UN says more than 100,000 civilians, displaced by fighting, are now in desperate need of assistance.
Rashid says the IMU remains a coherent organization despite losing leaders and fighting in Pakistan during the past decade. Its long-term alliance with the Taliban, he argues, helps it now carve sanctuaries in northern Afghanistan.
The Afghan Taliban sheltered IMU members in the late 1990s. After the regime's demise as the result of U.S.-led military operations in 2001, the IMU moved into Pakistan's northwestern tribal areas, where they bonded with Al-Qaeda and Afghan and Pakistani Taliban factions.
One of the IMU's founders and its main ideologue, Tahir Yuldashev, was killed by an alleged U.S. drone strike in August 2009. His successor, Osman Adil, was killed in a similar attack. Both were close allies of Tehrik-e Taliban Pakistan and were killed in the Waziristan region.
Current IMU leader Usman Ghazi
A Pakistani military operation beginning last June pushed the IMU back into Afghanistan from their sanctuary in North Waziristan.
"Even though some of them [IMU fighters] have pledged loyalty to Islamic State (IS) in Iraq, they maintain their loyalty to the Taliban not only to survive but to grow," Rashid said.
Hekmatullah Azamy, a researcher at the Kabul-based Centre for Conflict and Peace Studies, agrees. Based on conversations with Afghan officials, he estimates the number of IMU fighters now operating in Afghanistan is between 5,000 and 7,000.
"It is difficult to distinguish between IMU fighters and their Taliban allies from northern Afghan ethnic groups," Azamy told RFE/RL Gandhara.
Azamy says the IMU first pledged allegiance to IS in September 2014 and current leader Usman Ghazi reiterated its support in March. He questioned the nearly 14-year absence of Afghan Taliban leader Mullah Muhammad Omar and called IS leader Abu Bakr al-Baghdadi "Caliph."
The group had previously vowed loyalty to Omar. Azamy, however, says the group retains strong bonds with the Afghan Taliban.
"There might be some changes on the leadership level, but their rank and file still work closely with the Afghan Taliban," he said. "They need each other. The IMU knows if it opposes the Taliban then the Afghan Taliban won't allow them to operate from their country."
Last year the IMU claimed responsibility for attacking Pakistan's Karachi airport
There is evidence on the Afghan frontlines that despite the IMU's newfound affiliation with the IS, it maintains its alliance with the Taliban.
Kunduz Governor Mohammad Omer Safi told RFE/RL the bodies of 18 foreign militants have been retrieved since April 24 from areas where Afghan forces are battling insurgents.
Safi said the dead included fighters from Tajikistan, Uzbekistan, Kyrgyzstan, Turkey, and Chechnya.
During the past six years, the IMU has been trying to establish a foothold in northern Afghanistan by embedding with the Taliban and radicalizing the region's Uzbek, Tajik and Turkmen communities.
Azamy says the IMU sent reinforcement to the Afghan Taliban from safe havens in Pakistan to counter the U.S. troop surge that began in 2009.
"They have mutual friends and enemies," he said. "One of the IMU's founders, Juma Namangani, was killed in Afghanistan while fighting for the Taliban in 2001."
Azamy says the IMU has in recent years become an umbrella organization for Jundallah, Junad al-Khalifa, Jamaat Ansarullah and the Islamic Jihad Union, which support its goal of destabilizing Central Asian governments to eventually replace them with an Islamic regime.
"In a diversionary tactic, militant groups sometimes split and then reunite," he said. "These groups are fighting in Afghanistan to form a base and project their power into Central Asia."
Tahir Yuldashev, IMU leader killed in 2009.
He says that after operating in northern Afghanistan for years, the IMU has become a stakeholder in Afghanistan's multibillion-dollar illicit economy with the Taliban and other transnational groups.
"The IMU has a vital role in securing the northern route into Central Asia and Europe for the Taliban and the international drug mafia," he said. "For now, Afghanistan's northern provinces are a safe haven."
The IMU controlled the route from the late 1990s until December 2001, when a U.S.-led campaign forced them to carve a new sanctuary in Pakistan.
Rashid says that even if the Taliban and Kabul strike a peace deal, the IMU will continue to be a destabilizing factor.
"If there is a ceasefire between the Taliban and the government in Kabul, would that ceasefire at some stage include the IMU?" he asks. "It might include the IMU inside Afghanistan but not necessarily fighters who are trying to get back into Central Asia."
Azamy says that unlike the IMU-Taliban alliance, Afghanistan and its northern neighbors are not ready to present a joint front to their common adversaries.
"Sometimes it is wise to just learn from your enemies," he concluded.