Ernest J. Moniz, the nuclear scientist and secretary of energy, who oversees the atomic labs, said in an interview that as the Obama administration sought technical solutions at the talks, diplomats would have been stumbling in the dark “if we didn’t have this capability nurtured over many decades.” Although Mr. Moniz would not discuss the secret plant at Oak Ridge, parts of which date to the American and Israeli program to launch cyberattacks on Iran’s Natanz enrichment plant, he said more generally that the atomic labs give the United States “the capacity to carry through” in one of the most complex arms-control efforts in history.

It has also changed the labs. In the bomb-making days, the scientists largely kept to their well-guarded posts. But anyone traveling to the Iran talks over the past year and a half in Vienna and Lausanne, Switzerland, saw the Energy Department experts working hard as the negotiations proceeded, and heading out to dinner after long days of talks.

It was over one of those dinners in Vienna last summer that several of the experts began wondering how they might find a face-saving way for Iran to convert its deep-underground enrichment plant at Fordo, a covert site exposed by the United States five years ago, into a research center. That would enable Iran to say the site was still open, and the United States could declare it was no longer a threat.

“The question was what kind of experiment you can do deep underground,” recalled a participant in the dinner. By the time coffee came around, the kernel of an idea had developed, and it subsequently became a central part of the understanding with Iran that Secretary of State John Kerry and Mr. Moniz announced this month. Under the preliminary accord, Fordo would become a research center, but not for any element that could potentially be used in nuclear weapons.

Sometimes, during negotiations in Switzerland, a member of the scientific team would dump a bowl of chocolates on the table and rearrange them to show the Iranians how a proposed site rearrangement might work. “It was a visual way,” an official said, “to get past the language barrier.”