Iran has promised to make drastic cuts to its nuclear programme in return for the gradual lifting of sanctions as part of a historic breakthrough in Lausanne that could end a 13-year nuclear standoff.
The "political understanding", announced on Thursday night in the Swiss city's technical university, followed 18 months of intensive bargaining, culminating in an eight-day period of near-continuous talks that went long into the night, and on Wednesday, all the way through the night.
Reading out a joint statement, the European Union foreign policy chief, Federica Mogherini, hailed what she called a "decisive step" after more than a decade of work.
The Iranian foreign minister, Mohammad Javad Zarif, told reporters the agreement would show "our programme is exclusively peaceful, has always been and always will remain exclusively peaceful", while not hindering the country's pursuit of atomic energy for civilian purposes.
The US secretary of state, John Kerry, mindful of scepticism back in the US, declared: "A final deal will not rely on promises; it will rely on proof."
Speaking in Washington shortly after the announcement, Barack Obama immediately sought to sell the deal to sceptical US Congress, describing it as "the best option by far" and warning that pulling out now could lead to another military conflict in the Middle East. If implemented, the agreement would "cut off every pathway that Iran could take to develop a nuclear weapon".
Obama acknowledged there would be "a robust debate in the weeks and months to come" but insisted the agreement was both the most peaceful and effective method to ensure Iran does not obtain a nuclear weapon. "If we can get this done, and Iran follows through on the framework that our negotiators agreed to, we will be able to resolve one of the greatest threats to our security, and to do so peacefully.
The declaration of a framework deal is both preliminary and partial. It does not cover all the issues in dispute and is intended to be only a precursor to a full comprehensive and detailed agreement due to be completed by the end of June. Before then, the understanding must survive attack from hardliners in Iran and the US.
But the joint statement and the details published in Lausanne represent a set of basic compromises that had eluded negotiators for many years. Iran will cut its nuclear infrastructure to the point that western governments are satisfied it would take a year to "breakout" and build a bomb, if Tehran chose to follow that path.
At the same time, Iran will open itself up to a level of monitoring and scrutiny of its nuclear programme that is likely to unparalleled anywhere in the world.
When all that has been achieved, which could be in as little as six months, the overwhelming bulk of international sanctions would be lifted and Iran would re-enter the global economy.
The accord also has the potential to be a turning point in normalising Iran's adversarial relations with the west, which have been a constant in world affairs since the Islamic revolution of 1979.
"This could be one of the most important diplomatic achievements in a generation or more," said Ali Vaez, an Iran analyst at the International Crisis Group.
The UK foreign secretary, Philip Hammond, said: "This is well beyond what many of us thought possible even 18 months ago."
But Israel dismissed the deal, and said it would continue to prevent a "bad" final agreement.
Strategic affairs minister Yuval Steinitz said in a statement after the announcements in Switzerland: "The smiles in Lausanne are detached from wretched reality in which Iran refuses to make any concessions on the nuclear issue and continues to threaten Israel and all other countries in the Middle East."
Among the main points of the understanding unveiled in Lausanne are:
Iran's infrastructure for uranium enrichment will be reduced by more than two thirds, from 19,000 installed centrifuges, to 6,104, of which only 5,060 will be used for uranium enrichment, for a period of 10 years.
Iran's stockpile of low enriched uranium will be reduced by 98% to 300kg for a period of 15 years.
Iran's heavy water reactor will be redesigned so it produces only tiny amounts of plutonium.
Iran's underground enrichment plant at Fordow will be turned into a research centre for medical and scientific work.
Iran will be open to enhanced inspections by the International Atomic Energy Agency for 20 years.
The first major test of the understanding will come in the next few days when Kerry is expected to present the details to a closed session of the Senate foreign relations committee,before a vote on a bill that would give Congress the power to accept or reject any nuclear agreement and another that would impose new sanctions.
Kerry's opposite number at the talks, Mohammad Javad Zarif, is expected to return to Tehran to a hero's welcome from a public desperate to escape the shackles of sanctions, but he has frequently warned his fellow negotiators that he will face a backlash from hardliners opposed to dismantling any of Iran's prized nuclear infrastructure.