The accord will keep Iran from producing enough material for a nuclear weapon for at least 10 years and impose new provisions for inspections of Iranian facilities, including military sites. And it marks a major shift since 2002, when the international community first discovered that Iran had covertly built nuclear facilities at Natanz and Arak. That same year, George W. Bush, in an infamous State of the Union address, labeled Iran a member of so-called “axis of evil.”

Speaking at the White House on Tuesday morning, President Barack Obama said the deal had “achieved something that decades of animosity have not.”

“This deal is in line with a tradition of American leadership,” he said. “This deal is not built on trust. It is built on verification.” He added, “No deal means a greater chance of more war in the Middle East.”

United Nations Secretary-General Ban Ki-moon was hopeful that the deal could help stabilize the Middle East.

“I hope — and indeed believe — that this agreement will lead to greater mutual understanding and cooperation on the many serious security challenges in the Middle East,” Ban said in a statement. “As such it could serve as a vital contribution to peace and stability both in the region and beyond.”

“This is a historic moment,” Iranian Foreign Minister Mohammad Javad Zarif said as he attended a final session alongside his international counterparts in Vienna on Tuesday morning. “We are reaching an agreement that is not perfect for anybody, but it is what we could accomplish, and it is an important achievement for all of us. Today could have been the end of hope on this issue. But now we are starting a new chapter of hope.”

The formal announcement of the so-called Joint Comprehensive Plan of Action was made after the meeting.

Diplomats said Iran agreed to the continuation of a U.N. arms embargo on the country for up to five more years, though it could end earlier if the International Atomic Energy Agency (IAEA) definitively clears Iran of any current work on nuclear weapons. A similar condition was put on U.N. restrictions on the transfer of ballistic missile technology to Tehran, which could last for up to eight more years.

Another significant compromise in the agreement concerns access to Iranian military sites. Iran's Supreme Leader Ayatollah Khamenei had previously ruled out inspections at the sites by U.N. nuclear inspectors, but Tuesday's agreement provides stipulation for inspectors to press for military locations as well, though the access is not guaranteed and the timing could be delayed.

Federica Mogherini, the European Union foreign policy chief, called the plan “a sign of hope for the entire world.”

Hassan Rouhani, the reformist president of Iran, tweeted, “#IranDeal shows constructive engagement works. With this unnecessary crisis resolved, new horizons emerge with a focus on shared challenges.”

Tuesday’s deal could prove to be one of the most consequential international diplomatic agreements in a generation, and marks a defining international achievement for President Barack Obama in a region where a multitude of political crisis and violent conflicts have stymied his policy goals.

While the agreement reached on Tuesday was concluded under the multilateral auspices of the P5+1, representing the permanent five members of the United Nations Security Council — United States, Russia, China, France, Britain — plus Germany, the ability to reach an agreement was largely a function of a diplomatic opening between Washington and Tehran that began in earnest in 2013, after the election of Rouhani in June of that year.

Rouhani was elected in part on a platform of renewed engagement with the West as means of overcoming Tehran’s international pariah status and trying to end a crippling international sanctions regime imposed on the nation. Khamenei backed Rouhani’s efforts to restart negotiations with the West that had largely proved ineffective during the president’s predecessor, the hawkish Mahmoud Ahmadinejad.

For its part, the Obama administration and its P5+1 partners seemed eager to again come to the table after nearly a decade of sanctions on Iran not only failed to curb Tehran’s enrichment activities but saw the program grow markedly larger since the first United Nations Security sanctions were imposed in 2006.

The new diplomatic opening lead to the signing of a Joint Plan of Action (JPOA) between Iran and the P5+1 in November 2013 in Geneva. The interim agreement froze Iranian nuclear enrichment in exchange for modest sanctions relief, after which the parties set out to conclude a long-term agreement which would target the removal of all sanctions for across the board limits to Iran’s nuclear activities.

Under the terms of the JPOA, the time period by which a final agreement was to be concluded was extended twice, leading to the breakthrough in the Swiss city of Lausanne on April 2015, whereby Iran and the world powers outlined a provisional framework that would guide the final stretch to codify a final agreement.

Since then, negotiators have worked out a number of technical details pertaining to the implementation of a deal agreed to by six nations and involving multiple international organizations, all while remaining cognizant of political realities threatening to derail an effective agreement.