The Russian government does not fear a direct threat from the Taliban as much as it is worried about Central Asian fighters who could use Afghanistan as a staging ground to penetrate Russia’s borders. One group of particular concern is the Islamic Movement of Uzbekistan, some factions of which have pledged allegiance to the Islamic State. Afghan officials have also reported the presence of militants from Tajikistan, Chechnya and Chinese Uighurs, many who relocated to Afghanistan from Pakistan’s tribal areas.

Fighting drug trafficking rings that partially fund the Afghan insurgency had been an area of common interest for the Russians and the Americans, said Yuri V. Krupnov, an adviser to the head of Russia’s antidrug agency, Viktor P. Ivanov. But that stopped when the United States Treasury Department in 2014 imposed sanctions on Mr. Ivanov, a close associate of Mr. Putin’s.

“Washington had no dialogue with us, and just asserted its interests and sovereignty, and was uninterested in the views of Russia or anybody else,” Mr. Krupnov said, adding, “The Obama administration buried this promising line of cooperation. All room for cooperation is exhausted.”

The alliance between the foreign militants in Afghanistan may not be as threatening as Russia fears. In Badakhshan Province, the number of foreign fighters is estimated to be about 500, some traveling with their families, Taliban commanders there say. The largest group is Tajik fighters, followed by Uzbeks from the Islamic Movement of Uzbekistan. Chechens and Uighurs have a smaller presence.

The militants from Central Asia have been problematic to their Afghan Taliban guests, the local commanders say, because they use harsher methods, and, somewhat scandalously, are more relaxed in how they observe Islam. On top of all of that, the local Taliban have grown furious that some of their guests have recently warmed toward the Islamic State, which they see as intruding on their turf.

“The Quetta Shura insisted that we treat them nicely, that they need our cooperation, but they have a lot of shortcomings,” said Malawi Amanuddin, the Taliban’s shadow governor in Badakhshan. “They say they are waging jihad, but their women here walk around not covering themselves according to Islamic hijab.”

It is these internal rifts, perhaps, that have encouraged Russian officials to explore their channels directly with the Taliban and drive a wedge deeper between the militants who threaten Russia and their Afghan hosts.

“The official position, and this is from the Ministry of Foreign Affairs, is that Russia is risking a lot and has nothing to gain” from cooperating with the United States, Aleksei V. Malashenko, a researcher at the Carnegie center in Moscow, said in a telephone interview. “We couldn’t agree on Georgia, on Ukraine and on Syria; why get involved in another conflict where we cannot agree?” he said, describing the Russian position as “let the Americans boil.”