World powers have reached a deal with Iran on limiting Iranian nuclear activity in return for the lifting of international economic sanctions.
US President Barack Obama said that with the deal, "every pathway to a nuclear weapon is cut off" for Iran.
And President Hassan Rouhani said the "historic" deal opened a "new chapter" in Iran's relations with the world.
Negotiations between Iran and six world powers - the US, UK, France, China, Russia and Germany - began in 2006.
The so-called P5+1 want Iran to scale back its sensitive nuclear activities to ensure that it cannot build a nuclear weapon.
Iran, which wants crippling international sanctions lifted, has always insisted that its nuclear work is peaceful.
There has been stiff resistance to a deal from conservatives both in Iran and the US. The US Congress has 60 days in which to consider the deal, though Mr Obama said he would veto any attempt to block it.
The Republican Speaker of the US House of Representatives, John Boehner, said the deal would only only "embolden" Tehran.
"Instead of stopping the spread of nuclear weapons in the Middle East, this deal is likely to fuel a nuclear arms race around the world," he added.
Israel's government has also warned against an agreement.
Prime Minister Benjamin Netanyahu said it was a "stunning historic mistake" that would provide Iran with "hundreds of billions of dollars with which it can fuel its terror machine and its expansion and aggression throughout the Middle East and across the globe".
He said he did not regard Israel as being bound by this agreement. "We will always defend ourselves," he added.
In a televised address, Mr Obama insisted the deal would make the world "safer and more secure", and provided for a rigorous verification regime. "This deal is not built on trust - it is built on verification," he said.
Immediately afterwards, Mr Rouhani gave his own televised address, in which he said the prayers of Iranians had "come true".
He said the deal would lead to the removal of all sanctions, adding: "The sanctions regime was never successful, but at the same time it affected people's lives.''
After 12 years, world powers had finally "recognised the nuclear activities of Iran", he said.
Analysis: Jeremy Bowen, BBC Middle East editor
The agreement will change the Middle East, perhaps a lot, but at the moment no-one knows exactly how. The biggest question is whether it will reduce or increase the turmoil in the Middle East.
Iran and the world's big powers, most significantly the US, now have a habit of working together - but don't assume that will help automatically to resolve the crises and wars that Iran, the US and their allies are involved with in the region.
There is a danger that mutual suspicion will heat up the Middle East's fault lines, especially the cold war between Iran and Saudi Arabia - and with it sectarian conflict between Shia and Sunni Muslims.
But the agreement in Vienna removes Iran's nuclear programme from the danger list. Two years ago, as Israel threatened to bomb Iran, it looked likely to lead to a major Middle East war. That in itself is a major diplomatic achievement.
Both Mr Rouhani and Iranian Foreign Minister Mohammad Javad Zarif referred to the dispute over Iran's nuclear programme as an "unnecessary crisis".
Mr Zarif said the deal was "not perfect for anybody'', but that it was the "best achievement possible that could be reached".
Mr Obama, who is trying to persuade a sceptical US Congress of the benefits, said it would oblige Iran to:
remove two-thirds of installed centrifuges and store them under international supervision
get rid of 98% of its enriched uranium
accept that sanctions would be rapidly restored if the deal was violated
permanently give the International Atomic Energy Agency (IAEA) access "where necessary when necessary"
Sanctions relief would be gradual, Mr Obama said, with an arms embargo remaining in place for five years and an embargo on missiles for eight years.
Separately, the IAEA and Iran said they had signed a roadmap to resolve outstanding issues.
IAEA head Yukiya Amano told reporters in Vienna, Austria, that his organisation had signed a roadmap "for the clarification of past and present outstanding issues regarding Iran's nuclear programme".
He called the agreement a "significant step forward", saying it would allow the agency to "make an assessment of issues relating to possible military dimensions to Iran's nuclear programme by the end of 2015".