"The fact is, none of Iran’s actions hold a candle to the things the Pakistanis have already done, and continue to do."

With Senator Barbara Mikulski (D-MD) having now announced her support for the U.S.-Iran nuclear agreement, President Obama has thirty-four senators in favor, making the deal all but done.

Beyond its main purpose, the agreement with Iran affords us a historic opportunity to get right what we’ve gotten wrong in Afghanistan ever since September 11. When we went into Afghanistan in the aftermath of the attacks, we chose to rely on the one country least likely to help us win: Pakistan. Our dependence upon Pakistan to supply the war effort allowed it to play a double game that has cost the lives of thousands of American troops and many more Afghans.

Some U.S. officials counter that we had no alternative. Actually, we may have: Iran.

Iran’s then president Mohammad Khatami strongly supported the war and our efforts to rehabilitate Afghanistan. The Iranians helped us strategize on Afghanistan at the Bonn conference in December 2001, and even insisted upon putting the word “democracy” in Afghanistan’s constitution.

Iran also has two ports—Bandar Abbas and Chabahar—that would have enabled us to resupply our troops in Afghanistan. Had we seized upon Khatami’s early support, we could have given ourselves more options, and avoided being solely dependent upon the perfidies of Pakistan. Instead, after only two months, the Bush administration cast Iran into the “Axis of Evil,” at which point Tehran became increasingly opposed to U.S. efforts.

Critics of the U.S. nuclear agreement charge that we can’t deal with the Iranians because Tehran is a malicious actor bent on nuclear proliferation, and whose proxies thirst for American and Israeli blood. Yet we have spent the past fourteen years paying the Pakistanis—who already have nuclear weapons—no less than $30 billion to draw real American blood on the fields of Afghanistan. Pakistan has used Islamist militants as tools of its foreign policy ever since 1947, and harbored notorious enemies of the United States from the Taliban’s Mullah Omar to Osama bin Laden himself.

Like the Iranian regime, it is not our rhetoric so much as our real policies that do us the most harm. We refuse to collaborate with governments we dislike, even in the service of defeating common enemies. That has hamstrung us in ways that may cost us victory in Afghanistan, and have greatly strengthened the rampaging hordes of ISIS in Syria and Iraq.

The prospect of cooperation with Iran, even if slow and tentative at first, could help considerably on both fronts.

If we were to mend fences with the Iranians, we could ship supplies to our troops and the Afghan army through Chabahar, and the road and rail links that connect that port to Afghanistan that the Indians helped build. Instead, we continue to rely on Pakistani supply routes—rendering us unable to confront the reality that Pakistan takes our money and kills our troops in Afghanistan. Rapprochement with Iran would better position us to take a harder line on Pakistan, a necessary prerequisite to avoiding a near total reversal of our gains in Afghanistan.

We’ve come to this pass in part because we’ve misunderstood our own recent history.

In 1990, three years after the Soviet withdrawal from Afghanistan, President George H.W. Bush declined to certify that Pakistan did not possess a nuclear weapon. As a result, the sanctions of the Pressler Amendment came into force, after which Pakistan could no longer receive U.S. military assistance.

Many Republicans and Democrats alike cite the Pressler Amendment as an example of failed sanctions, arguing that the legislation did not prevent the Pakistanis from testing nuclear weapons in 1998. These critics also claim that that the cutoff in U.S. aid resulted in the rise of the Taliban, Al Qaeda’s move to Afghanistan and eventually the events of 9/11.

This reasoning is flawed on both counts. According to former Pakistani Foreign Minister Abdul Sattar, sanctions would not have prevented the Pakistanis from developing a nuclear weapon in 1990—because they already had one as early as 1980.

In fact, the Pressler Amendment allowed us to resupply the Pakistanis in our proxy war against the Soviet Union, even though U.S. intelligence knew Pakistan was developing nuclear capability. After all, the Carter administration first sanctioned Pakistan for nuclear proliferation in April 1979. From 1982 to 1985, when Pressler was passed, all security assistance required a waiver of those 1979 sanctions.

Second, the 1990 cutoff did not require the United States to outsource our Afghanistan policy to Pakistan altogether. But this is exactly what we did, and it was that decision that ultimately resulted in the rise of the Taliban, their cooperation with Osama bin Laden and the attacks of September 11.

Although we’ve long since swapped seats with the Soviets, we once again find ourselves in a similar predicament in Afghanistan. With our total reliance on Pakistan having denied a clean victory, we now hope Islamabad will help us find a tolerable exit from that war, in exchange for calling the shots after our departure. This is a sure recipe for failure, but Pakistan remains our only other neighboring ally with an available port.

India and Iran share the strong American interest in fighting Sunni militancy in Afghanistan. U.S. and European sanctions on Iran hindered Indo-Iranian collaboration during the very years when we should have done everything in our power to encourage it. The prospect of lifting these sanctions under the U.S.-Iran nuclear agreement may be too little, too late. But it will surely be a welcome change for two regional powers we can no longer afford to alienate.

The fact is, none of Iran’s actions hold a candle to the things the Pakistanis have already done, and continue to do. The nuclear agreement could give the United States and its international partners a way of sustaining its military presence in Afghanistan, and increasing the pressure on Pakistan to cease and desist from employing jihadi proxies under its expanding nuclear umbrella. India and Iran would welcome this development, and we should welcome it, too.

Afghanistan may already be slipping from our grasp. But with Iran as a partner, we may no longer be compelled to simply roll over and lie prostrate before the Pakistanis. It served us poorly before September 11, and it serves us no better today.

C. Christine Fair is an associate professor in the Security Studies Program of the Edmund A. Walsh School of Foreign Service at Georgetown University.