After a month of often contentious debate, there was agreement where none seemed possible.
Deeply divided delegates at a UN conference - representing nearly 200 countries - approved steps to strengthen the Nuclear Non-Proliferation Treaty (NPT).
An agreement was seen as essential to rescue the treaty from a decade of deadlock between those states that have nuclear weapons and those that do not.
Ironically, what clinched the deal was a decision to move towards a Middle East zone free of nuclear weapons, that was immediately beset by controversy.
The final declaration resolved to hold a Middle East conference in 2012, not to establish such a zone, but to begin the process of establishing one.
This apparently modest achievement was the result of weeks of tense negotiations.
That is because only one Middle Eastern state is believed to have nuclear arms - Israel - and it is not a party to the NPT. Arab countries see the regional conference as a first step to disarming Israel's atomic arsenal.
Some only signed up to the anti-nuclear treaty after a promise 15 years ago by atomic weapons states that such a zone would be established.
Now they insisted on action, and the US, Israel's strongest ally, agreed in order to keep the UN non-proliferation review from collapsing.
But Washington was furious at Arab insistence that Israel be named in the document.
While welcoming the agreement reached at the NPT Conference as a boost for his foreign policy agenda of non-proliferation, President Barack Obama said the US strongly opposed "efforts to single out Israel" and would "oppose actions that jeopardise Israel's national security".
US National Security Advisor General James L Jones went further.
"Because of the gratuitous way Israel has been singled out, the prospect for a conference in 2012 that involves all key states is now in doubt and will remain so until all are assured that it can operate in an unbiased and constructive way," he said.
However, diplomatic sources said none of the other countries involved in the negotiations objected to naming Israel, including those from the small club of nuclear weapons states.
And the Middle East meeting is now part of the NPT Conference Action Plan and will come up for regular review, something the Arabs saw as an achievement, even if Israel refuses to attend.
'Iran the winner'
If the Americans were angered by the mention of Israel, they were frustrated by the refusal to mention Iran, a country they believe is trying to develop nuclear weapons.
Since decisions have to be made by consensus, Iran has virtual veto power. So Washington was unable to single it out for violations of UN Security Council resolutions.
The US and other Western nations had also wanted much tighter inspections on civilian nuclear programmes like Iran's, something for which there was widespread opposition from non-nuclear weapon states.
In fact, said one observer, "Iran was the winner at the conference".
But Iran did not get everything its own way. At the 11th hour its nuclear ambassador, Ali Asghar Soltanieh, threatened to block a final declaration unless atomic weapons states agreed to a deadline for disarming. They had stripped the text of any reference to a time-frame.
Here too nations without nuclear weapons shared Iran's frustrations, but, said diplomatic sources, they did not want the conference to fail and so pressured Iran to compromise.
Isolated, Iran accepted that the "limited measures" in the document were a "step forward" and joined the consensus.
Are we safer?
Will this hard-won declaration actually make the world a safer place?
That is not clear.
Activists here say the differences between nuclear haves and have-nots enshrined in the treaty have so polarised positions that significant disarmament, and a tighter inspection regime are not possible.
But however flawed some believe the existing non-proliferation machinery to be, all agree that it has at least been partially rehabilitated after a decade of failure.
The final declaration showed a collective international will to deal with nuclear threats, and that is being hailed as a success.