Iranian Foreign Minister Mohammad Javad Zarif speaks at a news conference in Tehran on Aug. 5, 2019. (Ebrahim Noroozi/AP)

In late 2018, as it became clear that the United States was contemplating a withdrawal from Afghanistan, the Iranian military announced that it was taking charge of the security of the border between Afghanistan and Iran. This indication of Tehran’s increased concern resulted from the prospect of renewed instability and insecurity.

Just a few weeks later came an exchange of visits between Tehran and Taliban delegations. Iranian and Taliban representatives weren’t meeting for the first time, but, in a departure from the past, the Iranians publicized these meetings.

Alongside these developments, Iranian Foreign Minister Mohammad Javad Zarif acknowledged that his country had some level of cooperation with the Taliban. He also summarized Iran’s current thinking on the Taliban: “It would be impossible to have a future Afghanistan without any role for the Taliban.”

How did Iran’s recently publicized relationship with the Taliban come about, and how might it affect the future of U.S.-Taliban talks?

Economic ties

Iran has become an important economic lifeline for war-torn Afghanistan: Tehran became Kabul’s biggest trading partner last year. The trade volume is so significant that the Trump administration has allowed for some sanctions exemptions to enable the completion of Iran’s Chabahar port even as the United States has pushed a “maximum pressure” strategy against the country. The exemption would allow India to continue developing an area in southeastern Iran that is important for the Afghan economy.

Iran is also home to millions of Afghan refugees. Iran has repatriated several hundred thousand Afghans, whose return could place additional stress on the Afghan economy.

Foes in need

Although the United States and Iran cut diplomatic ties during the 1979-1981 hostage crisis, the two countries have had rare instances of rapprochement. Among these diplomatic overtures is the U.S.-Iranian cooperation that characterized the early days of the U.S. military campaign in Afghanistan in 2001. It was instrumental in establishing the new government in Kabul, according to James Dobbins, who served as President George W. Bush’s envoy to Afghanistan. While this U.S.-Iranian cooperation was short-lived, Iran still tolerated the U.S. and NATO presence in Afghanistan.

Tehran largely refrained from engaging in nefarious activities in Afghanistan. Unlike faraway theaters such as Syria and Yemen, Afghanistan’s security and stability are directly relevant to Iran’s own. Tehran is much more risk-averse and, as such, less inclined to accept the costs of pushing back the United States in Afghanistan than it would have been in a less-proximate theater.

U.S. and Iranian interests also aligned in other areas, albeit to varying degrees. Both countries (and NATO allies of the United States) were concerned about a new refugee influx, opioid trafficking, and the possible return of the Taliban and al-Qaeda to Afghanistan and those groups’ ability to operate and threaten their borders and populations from there.

Iran’s new partner

By the end of the first decade of the war, Iran’s stance toward the Taliban was beginning to change. The rise of the Islamic State’s offshoot in Afghanistan, known as the Islamic State in the Khorasan Province (ISKP), deeply troubled Iranians beginning in 2014. The country had already witnessed its western neighbor, Iraq, succumb to the terrorist group’s power grab and territorial control. Islamic State leaders and operatives made it clear they were also planning attacks on Iranian soil.

Tehran came to see the Taliban as the lesser of two evils, viewing cooperation with the insurgents as a check on ISKP — even as events on the ground proved more complex and the relationship between ISKP and the Taliban more fluid. A number of interests led Iran to form a partnership with the Taliban.

Beginning in 2016, Iranian officials believed that their country’s main rival, Saudi Arabia, was becoming more assertive in Afghanistan and sought to stymie Riyadh’s progress there. This occurred against the backdrop of heightened Saudi-Iranian tensions after the two Middle Eastern powers severed ties that year. Iran viewed it as imperative to create a bulwark against a Saudi domination of the Afghan political, security and religious landscapes by forging ties with groups beyond its traditional allies (chiefly, the Northern Alliance). But Iranians saw the rise of the Taliban as a fait accompli and tried to forge ties with some Taliban groups whose more-moderate positions made them decent candidates for cooperation.

This wasn’t a novel approach by Tehran, which has long preferred some cooperation to confrontation with groups it considers a threat to its security (including al-Qaeda).

But ideology also played a role in forging ties between Iran and the Taliban: Both shared the objective of undermining the U.S. presence in Afghanistan and the broader neighborhood. Although Iran didn’t wish to see a complete U.S. withdrawal from Afghanistan, which it believed would lead to the country’s descending into chaos again, Tehran did want the American presence there minimized.

From covert to overt

Tehran’s support for the Taliban remained largely covert until last year. In fact, Iranian officials often dismissed or denied reports that their country was lending a hand to the insurgent group.

In 2018, some signs indicated a possible move toward a more overt relationship between Iran and the Taliban. Tasnim News, an outlet associated with the Islamic Revolutionary Guard Corps’ intelligence, published a report that spring outlining the viability of the Taliban as a force countering ISKP, serving as a buffer against the Americans and as a de facto governing entity in parts of Afghanistan.

As the United States counts its losses and looks to pull troops from Afghanistan, Iran is finally publicizing its relationship with this important player in Afghan politics. This relationship with the Taliban now spans the economic, security and political realms and is likely to grow as the Taliban asserts itself again.

So far, Iran has largely refrained from actions that may derail or complicate the negotiation process but has the ability to take on that role. And the Taliban could leverage its ties to Tehran to make fewer concessions in the talks with the United States. Understanding what motivates Iran in Afghanistan could help mitigate these risks.

Ariane M. Tabatabai is an associate political scientist at the nonprofit, nonpartisan Rand Corp. and an adjunct senior research scholar at Columbia University.