The historic nuclear agreement between Iran and the P5+1 negotiators announced on July 14 is a transformative event for the Middle East, a victory for U.S. nonproliferation strategy, and will surely be one of U.S. President Barack Obama’s most consequential foreign policy achievements.

Auspicious as this occasion is, though, there is no guarantee that the agreement will survive, given how contentious the implementation phase is likely to be. Nor can the deal by itself end the lingering animosity between the United States and Iran, which predates the nuclear program. The landmark nuclear agreement will only be sustainable if it continues to serve the national interests of both countries. And here, if they think beyond their strategic divorce in 1979 and the recent deal itself, they will realize that they have much to gain from improved ties—and that the agreement will be crucial to this process.

U.S. Secretary of State John Kerry meets with foreign ministers and delegations from Germany, France, China, Britain, Russia and the European Union at a hotel in Vienna, July 13, 2015. Carlos Barria / Reuters To be sure, those in Tehran and Washington who oppose the deal—and those countries in the Middle East that have benefited from Iranian-U.S. estrangement—won’t make things easy. Still, the agreement is a risk worth taking, considering how unattractive the other alternatives are. Indeed, although the United States and Iran did not get everything they wanted in the negotiations, the agreement is the best they could possibly attain at this juncture. It is a “win-win” for both countries, and a triumph of diplomacy and hope over war and cynicism.

TURN DOWN FOR WHAT?

As Congress begins deliberations about the agreement, opponents will relentlessly lobby legislators to reject the deal on the grounds that it has not closed all pathways to a nuclear bomb and has legitimized Iran as a threshold nuclear power. But they will not be able to offer a viable alternative to it. Should Congress vote to reject the agreement anyway, Obama has promised to veto their decision. Overriding his veto would require a 2/3 majority in both houses of Congress, which is unlikely. Moreover, doing so would profoundly tarnish U.S. prestige and make it extremely difficult for Washington to sustain the existing sanctions regime on Iran. In other words, the chances that the agreement will survive Congressional opposition are good.

The breakout time for Iran to build a bomb, should it ever decide to do so, will be extended from the estimated two to three months to more than one year.

If opponents fail to scuttle the deal under Obama, though, they will seek to convince Congress and the next president to continue and possibly intensify Washington’s containment of Iran. They will warn that lifting the sanctions and unfreezing Iran’s estimated $110 billion in foreign assets will make the country more eager to destabilizing the Middle East. They will insist that anti-Americanism remains a foundational principle of the Islamic Republic. What they will not mention, of course, is that the U.S. policy of containing Iran for years has not worked and has helped transform Iran into a regional power

The P5+1 agreed to lift nuclear-related sanctions on Iran because the negotiators were convinced that all pathways for Tehran to build a bomb Iran had been satisfactorily closed and that its key nuclear activities would be seriously curtailed or frozen for at least a decade. The Joint Comprehensive Plan of Action, released on July 14, is a detailed and highly technical document that outlines in methodical detail the responsibilities of Iran and the six global powers. According to the document, Iran offered major concessions. It agreed to stop enriching uranium at 20 percent, a process only a few countries have mastered. Iran also consented to reduce the number of its centrifuges by two-thirds and to redesign the core of the heavy-water reactor at Arak so that it cannot produce weapons-grade platinum. Altogether, Iran will be compelled to get rid of 98 percent of the entire stockpile of its enriched uranium, which it can ship out of the country or sell. At any one time, Iran will be allowed to have inside the country only a fraction of the enriched uranium it would need to build a bomb.

The net result of these restrictions is that the breakout time for Iran to build a bomb, should it ever decide to do so, will be extended from the estimated two to three months to more than one year. This will give the West ample time to stop Iran from going nuclear.

The critics of the deal insist that they still don’t trust Iran. They shouldn't. Nor does Iran trust the West. That can come only slowly and through confidence-building measures, of which this deal is a good start. Verification, transparency, and continuous monitoring of the Iranian nuclear facilities will also help. In fact, Iran has accepted the most intrusive inspection and monitoring regime ever imposed on a member of the Non-Proliferation Treaty, including continuous monitoring of the Fordow facility, which is a highly fortified underground facility designed to withstand aerial bombardment. Iran has agreed to allow the International Atomic Energy Agency to inspect, where and when necessary and in consultation with Iran, any suspected Iranian military facilities. Tehran has also agreed to answer all questions pertinent to the military dimensions of its past nuclear activities.

HARDLY HARDLINE

Iranian Foreign Minister Mohammad Javad Zarif gestures as he talks with journalist from a balcony of the Palais Coburg hotel where the Iran nuclear talks meetings are being held in Vienna, July 10, 2015. Carlos Barria / Reuters It will not be easy to sell the deal in Iran. Some hardliners will lament that Tehran has capitulated to the West. One such critic sarcastically tweeted that Iran’s nuclear program is reduced to centrifuges that only can produce atomic carrot juice. But hardliners will have no better alternative than the new deal. And those in Congress who worry about them should not dismiss the profound changes that have taken place in Iran and their potentially positive impact on the U.S.-Iranian relations. As I argued in a 2009 Foreign Affairs article, Iranian foreign policy rests on two pillars: the survival of the Islamic Republic and anti-Americanism. For a while now, those two pillars have been mutually reinforcing; ruling elites believe that Washington seeks regime change, so Iran has seen itself as being on the defensive, trying to deter the United States and expand its regional influence as a hedge. A recently declassified report by the Pentagon from 2010, “Military Power of Iran,” supports this perspective.

But there are signs that the Islamic Republic’s and the Iranian population’s perceptions of the U.S. threat are gradually changing. Polls of Iranians unambiguously reveal that a significant portion of Iran's highly educated population, particularly its technology-savvy youth, favor improved relations with the United States.

Opponents of the deal dismiss these facts, arguing that Iran's hostile policies are not made by its people but by its authoritarian leaders. But that line of thinking ignores the development of a new faction within the governing elite that seeks to improve relations with the United States without undermining Iranian sovereignty. Although there are powerful forces that still oppose any rapprochement with the United States, direct nuclear negotiations between Tehran and Washington seem to have convinced many in the country that the United States has finally and explicitly recognized the legitimacy of the Islamic Republic as well as its right to indigenously enrich uranium.

Without any introspection, hardliners in Tehran and Washington will focus only on their grievances. Instead, they should concentrate on common goals.

This elite faction, of course, is not new. Hashemi Rafsanjani, who was president from 1989 to 97, for example, offered Conoco, an American oil company, a $1 billion deal in 1995 to develop the Sirri oilfields in Iran. U.S. President Bill Clinton scuttled the deal and imposed new sanctions on Iran. Mohammad Khatami, a reformist president who served from 1997 to 2005, reached out to the United States as well—but his efforts were futile. Even the pugnacious Mahmoud Ahmadinejad, president from 2005 to 2012, sought to negotiate with the United States to resolve the nuclear impasse. But his repugnant denial of the Holocaust made him so toxic that Washington refused to deal with him. But it was President Hassan Rouhani, backed by popular mandate, who started open negotiations. His success in getting a nuclear agreement is likely to strengthen members of this faction and increase their chances of winning in the parliamentary and presidential elections in 2016 and 2017, respectively.

Skeptics might argue that real power does not reside in the presidency, but rather in the Supreme Leader and the Revolutionary Guards. And Ayatollah Ali Khamenei, they maintain, is an inflexible zealot who will never make nice with Washington. But they are simply wrong. No Iranian president could have reached out to the United States without the Supreme Leader’s approval. Moreover, Iran’s Revolutionary Guards, which are exclusively accountable to Khamenei, cooperated with U.S. Special Operations Forces in 2001 to dislodge the Taliban government in Afghanistan. More recently, he has said that if “the U.S. behaves in a humane way, we will have no problem with it,” which, in the convoluted vernacular of Iran means we are ready to talk. It is also highly likely that the world will witness changes in Iran’s top leadership within the next decade, as Iran’s mostly septuagenarian leaders are replaced by younger and hopefully less idealistic ones.

All this presents a unique opportunity for Washington to improve relations with Tehran. The two have been tangled in a covert war for 37 years. Both have a long list of legitimate grievances. Without any introspection, hardliners in both Tehran and Washington will focus only on those grievances. Instead of focusing on that past, though, they should concentrate on common goals for the future. In truth, the United States shares more strategic interests with Iran in Afghanistan and Iraq, and against the Islamic State (also called ISIS) than it does with its other Persian Gulf allies.

Today Iran is a spoiler regional power—one that is insufficiently powerful to shape the Middle East to its own liking, but sufficiently powerful to make it costly for the United States to achieve its own goals. Its zone of influence stretches from Afghanistan to Iraq to the Levant and even to Yemen. Its power, particularly its soft power and its advances in asymmetric warfare strategies, cannot be ignored. Iran did not create the turmoil in these countries, but took advantage of the chaos to empower marginalized forces and expand its own sphere of influence. For Iran to become a part of the solution to stabilize the region, it must moderate its regional policies, particularly toward Bashar al-Assad’s brutal regime and toward Lebanon. The new agreement can provide a unique opportunity for Iran to move toward real moderation in its regional policies.

The key challenge for the United States is to provide strategic incentives to transform Iran from spoiler power to a cooperative one. The two powers can engage in managed tactical cooperation where their mutual interests coincide and compete with each other where their interests are irreconcilable. A good place to start would be on ISIS, which poses a profound threat to both countries and to the entire region. ISIS has expanded beyond Iraq and Syria to Saudi Arabia, Egypt, Yemen, Libya, Tunisia, and even Paris.

The United States does not want to put boots on the ground in Iraq or Syria to fight ISIS. But its aerial bombardment of ISIS facilities and fighters will not defeat the terrorist organization. Egypt, Jordan, and Saudi Arabia are unlikely to be willing to send troops; after all, the Shia-dominated government in Baghdad and the Assad regime in Damascus will vehemently oppose such an intervention. The powerful Turkish military is more interested in overthrowing Assad than defeating ISIS. And the Kurdish Peshmerga has the desire to fight ISIS, but not the capability to defeat it. And it is unlikely that the United States can train moderate, indigenous Arab forces as quickly as ISIS can recruit new members.

Iran, however, has the will and the power to “degrade and defeat ISIS” and has already done more to weaken the group than many of the United States’ Persian Gulf allies. Iranian-trained militias have a good record of fighting ISIS in Iraq and Syria. Members of the Revolutionary Guards have been in direct combat with ISIS. Iran was the first country to provide logistical support and equipment to Iraqi Kurds when they were threatened by ISIS in 2014. Iran has even helped Baghdad and Iraqi militias liberate a few towns in Iraq from ISIS control.

Skeptics say that any tactical cooperation between the United States and Iran will only antagonize the region’s Sunni population. Although there is an element of truth to this, it is essentially a subtle attempt to prevent detente between Tehran and Washington. Such a tactical cooperation should worry moderate Sunnis far less than ISIS does. Although the media often talks about Sunni alienation, it is worth remembering that the Shias are a majority in the oil-rich Persian Gulf and that the West should not seek to alienate them either. Moreover, the two main terrorist organizations, al Qaeda and ISIS, are Sunni not Shia.

Part of the problem is the role Saudi Arabia has been playing in trying to prevent an accord between Iran and the United States. For years, the Saudis have known that, as long as the United States remained dependent on imported oil and was antagonistic toward Iran, Riyadh could count on Washington’s unconditional support to pursue its regional ambitions. Today, however, Riyadh is in a state of panic. First the recent boom in U.S. oil production, backed by a new fracking technology, had made the United States less dependent on imported oil. And now there is also a possibility of a rapprochement between the United States and Iran, which will diminish the Kingdom’s strategic value.

For too long, Washington has given a free pass to the Saudis even as it has been rightly critical of Iran’s regional behavior. Saudi Arabia was one of the three countries that recognized the Taliban rule in Afghanistan, it sent troops to smash the pro-democracy uprising in Bahrain in 2011, and it provided financial support to the military takeover in Egypt in 2013 that overthrew the first democratically-elected president of that country. Some Saudi clerics continue to provide ideological justification for violent extremist groups, and some private citizens provide financial support to extremists. To prevent any serious discussion of whether these behaviors help or hurt U.S. interests in the region, Riyadh simply maintains that Iran is the main source of instability and that Washington needs to “cut off the head of the snake.”

Washington must slowly move away from its traditional and unconditional support of Saudi Arabia, but without fully undermining its alliance with the Kingdom. There, Washington can take a few risks. After all, Saudi Arabia cannot and will not find a better ally than the United States.

Washington must also seek a more balanced and nuanced approach toward the Saudi-Iranian cold war. A good place to start would be discussions among all three about Yemen and then Syria. But without the nuclear agreement and reduction of tensions with Iran, the United States would not be able to play this role, which would give it some maneuvering room to protect its national interests with minimal cost in the Persian Gulf and beyond.

When much of the Middle East is descending into unpredictable civil and sectarian wars, Iran is a regional lynchpin. A U.S. detente with the country can potentially help Washington achieve many of its goals in the Middle East. But this demands strategic imagination and patience. Almost two years ago, I wrote for Foreign Affairs that we can and should do business with Rouhani to resolve the nuclear impasse. Now its time to do even more.