MOSCOW — A Kremlin official said Wednesday that Russia was exchanging information with the Taliban, the Islamist insurgency that the United States has been fighting in Afghanistan since 2001, as a bulwark against the spread of the Islamic State militant group in that country.

Zamir Kabulov, a Foreign Ministry department head and President Vladimir Putin’s special representative for Afghanistan, told the Interfax news agency that “the Taliban interest objectively coincides with ours” in the fight against the Islamic State, which has captured broad swaths of territory in Syria and Iraq.

“I have already said earlier that we and the Taliban have channels for exchanging information,” Kabulov added, in remarks reported by Interfax and confirmed to The Washington Post by a ministry spokesman.

A limited partnership with the Taliban, which announced last week that it would send “special forces” to fight the Islamic State, is a striking, and somewhat confusing, twist in Russia’s war on terror. Although Russia plunged enthusiastically into its airstrike campaign against the Islamic State in Syria in September (critics say Russia is mainly there to prop up President Bashar Assad), Moscow has opposed the Taliban for more than a decade as a potential vehicle for terror and instability in the former Soviet Union.

Along with the Islamic State, the Taliban is on a Russian government list of terrorist organizations. Similar to the Islamic State, the Taliban is known for staging brutal public executions and imposing an extreme interpretation of Islamic law on the territories it has captured.

The grueling 14-year-old war in Afghanistan sparked by the Sept. 11, 2001, attacks has killed more than 3,400 troops from a U.S.-led NATO coalition and left the Taliban diminished but not defeated. In September, the Taliban captured the northern Afghan city of Kunduz for 15 days, the first major city captured by the Taliban since the U.S.-led invasion.

Although there are signs that the popularity of the Islamic State is growing in Afghanistan, including the mysterious Caliphate Radio station that broadcasts Islamic State propaganda every morning, the Taliban remains a far more potent force there.

After the capture of Kunduz, Russia reinforced its 201st Motorized Rifle Division military base in Tajikistan, a former Soviet republic that borders Afghanistan, sending attack helicopters in what was widely seen as a response to the resurgence of the Taliban in a city less than five miles from the border with Tajikistan.

In the same interview on Wednesday, Kabulov said Russia would be “ready to supply weapons but will do it with due prudence and mostly on a commercial basis” to Afghanistan. Those weapons would probably be used against the Taliban, which this week launched an offensive aimed at a strategically important district in Helmand province.

Maria Zakharova, a spokeswoman for the Foreign Ministry, said by telephone that Russia’s only shared interest with the Taliban is the fight against the Islamic State.

She also said that contacts between Russia and the Taliban have been limited. There has been “no travel, no meetings. It’s only information exchange,” she said.

Zakharova said that Russia was maintaining a sanctions regime imposed on the Taliban by the U.N. Security Council and that no material support had been supplied to the group.

She declined to discuss what information had been shared.