It is no secret that Iran has a murky foreign policy – for political analysts, it is almost as difficult as separating wheat from chaff. Recently and increasingly so, accusations are mounting that Iran is expanding its association with the Taliban in Afghanistan. In this regard, three questions need to be answered to clear up the sketchiness that surrounds the relationship between Iran and the Taliban: If indeed the accusations are true, then why the change in Iran’s policy; when did this policy change take place ; and what is the level of support afforded to the Taliban by Iran?

So far, history showcases the implausibility of the two parties colluding on any front. The Taliban’s Sunni-first ideology, its history of persecuting Afghan Shiites, and its attacks on Iranians make the group the unlikeliest of allies for Iran. In the late 1990s, the Taliban’s mediated efforts for an anti-Shiite program almost resulted in an all-out war with Iran. During the Afghan civil war, the Taliban aimed to ‘disinfect’ northern Afghanistan of Afghan, Shiite Hazaras – in the wake of which, thousands of Shiite Hazaras were massacred. In 1998, a small Taliban unit entered the Iranian consulate in Mazari Sharif, Afghanistan’s third largest city, and rounded up and butchered nine Iranian diplomats. Taliban units then moved to take over Bamiyan in Central Afghanistan, the nucleus of the Hazara ethnic group, and continued their slaughtering. Meanwhile, Iran’s Supreme Leader, Ayatollah Ali Khamenei even accused Pakistan of assisting the Taliban in capturing Bamiyan, and a force of 70,000 Iranian Revolutionary Guards and Iranian military forces, set up camps along the Iran-Afghanistan border.

Iran then became the main foreign sponsor of the Northern Alliance – the Taliban’s main domestic rival, and went on to implicitly collaborate with the United States in overthrowing the Taliban in 2001.

However, the dynamics took a 180-degree turn post-9/11. Iran ramped up its support to the Taliban, due to many events in Afghanistan, the chief of which was Washington’s erratic policy switch—from Obama’s scheduled cutting down troops in 2014 to the now apparently sealed deal resulting in increased US support. The recent dropping of the “mother-of-all-bombs” is evidence of this. The Trump administration’s turnaround has created the uncertainty in Afghanistan. Uncertainty which may have played a significant role in pushing Iran to hedge its bets vis-à-vis Afghan actors, specifically the Taliban.

With the current logjam period in US-Iranian relations, after the new US administration entered office, Iran’s leaders are apprehensive once again about the United States using Afghanistan as a base from which to launch potentials attack on their country. Thus, in the short term, at least, the Taliban is facilitating Iranian interests through its mutiny against the US-backed government.

Another crucial factor is the rise of the Islamic State (ISIS) in the eastern part of Afghanistan. ISIS, which harbours extreme hostility toward Shiites, has engaged fighters to Iran’s west in Iraq and to its east in Afghanistan. Unlike the Taliban ideology, ISIS’s dogma is transnational and can be used to provoke Iran’s already high-strung Sunni populations. Yet, also unlike the native Taliban, this transnational terrorist group depends upon various yokes of recruiting, caging, and coercing local groups in Afghanistan. The Taliban has grown to become one of ISIS’s primary enemies in Afghanistan, as ISIS competes with the Taliban, and aims to peel away discontented fighters from Taliban ranks. Taliban and ISIS fighters regularly clash. In early May, more than two dozen fighters were left dead after a confrontation in the eastern Nangarhar province.

By providing limited support to the Taliban, Iran is filling two needs with one deed: Creating a shield against ISIS and simultaneously preventing the United States from using Afghanistan as a launching pad against Iran.

The crucial year was of course 2014 because it represents the critical turning point when Iran shifted its stance with the Taliban. In this year, the vast majority of international combat troops withdrew from Afghanistan which was a major setback to the validity of the Afghan government. Iran then moved to officiate its relationship with the Taliban by giving its permission to open an office in its eastern city of Mashhad. Events such as several regional groups, including Al Tawhid Brigade and Ansar ul-Khilafat Wal-Jihad, pledging allegiance to ISIS also pushed Iran and the Taliban closer together.

According to officials quoted in the Wall Street Journal Report in 2015 Iran now runs at least four training camps for Taliban fighters, located in Tehran as well as in Mashhad, the city of Zahedan and the province of Kerman. Moreover, Iran’s Islamic Revolutionary Guards Corps have been arming and training the Taliban.

Media accounts have highlighted the increasing levels of support given to the Taliban, but as of now, it still seems that Iran mainly beholds the Taliban as a useful common adversary against both US led efforts in Afghanistan and the Islamic State. At this point, Iran will continue its marriage of convenience through providing just enough arms and training to the Taliban, which is different from a full-blown investment to change the equation in Afghanistan.

It seems that Iran is of the belief that the Taliban will ultimately play some part in the Afghan government – since enemies of today can become key political actors tomorrow. That being so, there is a benefit to maintaining a limited relationship for some sort of clout down the road.

However, it should be kept in mind that in the course of any drastic moves by either the United States or the Islamic State to modify the dynamics of the country, the Iranian leaders might, once again, have to reappraise their Taliban affinity.  For now, even though Iran’s Shia rulers sit at the opposite end of the religious spectrum from the Taliban’s Sunni fundamentalists, the two have become allies of convenience against common enemies.