Afghans near the Torkham border post burn a mock Pakistani flag on Feb. 19 to protest cross-border shelling that was intended to target the hideouts of suspected militants. (Ghulamullah Habibi/European Pressphoto Agency)

An escalating border conflict between Afghanistan and Pakistan is threatening to undermine their cooperation on terrorism and peace talks with the Taliban as the Trump administration begins weighing its options to spur progress on both fronts.

After a blitz of terrorist bombings across Pakistan left more than 125 people dead, Pakistani forces began shelling both sides of the border Friday, aiming at camps used by a group tied to the Islamic State that claimed most of the attacks. Pakistan also closed all border crossings.

Afghanistan has protested that the shelling is forcing hundreds of villagers to flee their homes. U.S. officials have asked Pakistani military leaders to cooperate with their neighboring country in going after the militants, but Pakistan has threatened to take further unilateral action.

And in a tit-for-tat exchange of demands, Pakistan asked Afghan officials Saturday to hand over 76 alleged militants based in Afghanistan, while Afghan diplomats Sunday called for action on a list of 32 terrorist training centers and 85 militant leaders they say are in Pakistan, including the Haqqani Taliban faction that is fighting against the Afghan state.

“Turmoil in Afghanistan has created space for terrorist organizations to find their foothold there,” said Nafees Zakaria, a spokesman for Pakistan’s Foreign Affairs Ministry. He said the group responsible for the recent bombings was based in Afghanistan as far back as 2014, when it massacred 141 people at a Pakistani army school, an assault that outraged the country.

Zakaria added that other countries in the region are concerned about the “growing footprint of groups like ISIS in Afghanistan.” The Islamic State is also known as ISIS.

Russia in particular has been seeking a role in solving the Afghan conflict, hosting regional meetings on it and expressing support for the Taliban as an antidote to a spillover of Islamic State groups into Central Asia. That approach has alarmed U.S. military officials who urged the Trump administration to raise troop levels in Afghanistan to block further Taliban advances.

There is plenty of irony in Pakistan’s finger-pointing. Afghanistan has long complained that Pakistan provides sanctuary for Taliban leaders and factions, a charge it denies. And the group most linked to last week’s bombings, Jamaat-ul-Ahrar, is an outgrowth of the Pakistani Taliban, which was driven into Afghanistan by a massive Pakistan army operation in 2015.

Once the group had relocated, some members split off and pledged allegiance to the Islamic State, a radical Sunni militia. Those militants have overrun several Afghan border districts, despite repeated efforts by Afghan forces to push them out, and they have claimed the bombing of several Shiite mosques in Kabul, the Afghan capital.

“Afghanistan is the victim of terrorism, not its shelter,” Gen. Dawlat Waziri, a spokesman for the Afghan Defense Ministry, declared Sunday. He called Pakistan’s border attacks “an act of aggression” and warned that if diplomatic efforts fail, “Afghans will defend their soil with whatever means available.” A Foreign Affairs Ministry official said Afghanistan might even seek U.N. sanctions against Pakistan for supporting terrorist groups.

Michael Kugelman, deputy director for Asian studies at the Woodrow Wilson International Center for Scholars in Washington, described Jamaat-ul-Ahrar as one of the Pakistani Taliban’s “most bloodthirsty factions,” with a “small but brutal contingent” in Afghanistan. 

In Pakistan, Kugelman added, the Islamic State has been forming “opportunistic partnerships” with radical religious groups of all kinds, including some that officials had for political reasons been reluctant to curb. The danger, he said, is of growing collaboration between the Islamic State and “high-octane local militant factions eager to latch onto its still-powerful brand.”

Given the common threat this phenomenon has created for Pakistan and Afghanistan, analysts pointed out, it would seem a perfect moment for their governments to join forces , especially when they are eager to prove to the new administration in Washington that they are serious about fighting Islamist insurgents and terrorists.

Instead, years of bitter acrimony between the two Muslim neighbors has fueled an explosion of highly politicized accusations and threats, reminiscent of a decade ago when Afghanistan’s then-president, Hamid Karzai, used to send lists of anti-Afghan militants living openly in Pakistan to its military president, Gen. Pervez Musharraf — with no result.

“The growing wave of terror in both countries requires a joint approach,” the News International newspaper here urged in its lead editorial Sunday. “The only beneficiary of increasing tensions between Afghanistan and Pakistan are terrorist groups. It is important to ensure that we, on both sides, do not resort to blame games.”

Today, the stakes for both countries are high. In Afghanistan, the 16-year war with the Taliban is at a stalemate, the defense forces are demoralized and stretched thin, and the government of President Ashraf Ghani is beset by divisions and administrative paralysis. 

Although the Trump administration appears likely to continue supporting the war with funds and troops, critics say the conflict cannot be settled unless the Ghani government takes decisive action to curb corruption, overcome ethnic rivalries, resume stalled election plans and mend fences with Pakistan.   

In Pakistan, the government of Prime Minister Nawaz Sharif has been struggling to rein in a panoply of militant Islamist groups without arousing further violence, to maintain a balance between military and civilian power and to navigate new relations with China and other partners while preserving long-standing security ties with Washington. 

Even before last week’s attacks, some influential U.S. policy experts had urged the Trump administration to sharply cut aid to Pakistan if it does not carry out a full-fledged crackdown on Islamist militants and begin playing a positive role in the effort to settle the Afghan war, rather than trying to manipulate it while providing refuge for anti-Afghan insurgents. 

Davood Moradian, director of the Kabul-based Afghan Institute for Strategic Studies, said success in Afghanistan was achievable — but only if three things happened.

“Afghanistan has to address corruption, strengthen the armed forces and integrate the Taliban into politics,” he said. “Pakistan has to abandon its strategy of using terrorism as a state policy. And the United States has to assure its allies and adversaries in both countries that it is determined to prevail.”