The prisoner swap was all arranged, or so the American negotiators thought.
After years of painstaking negotiations with Iran, secretly mediated by Persian Gulf nations, top aides to President Biden had finally struck a deal on June 6 that would free four Americans held in one of Iran’s most notorious prisons. In exchange, the United States would unfreeze $6 billion in Iranian oil revenue and drop charges against Iranians accused of violating U.S. sanctions.
The U.S. negotiators knew there could still be last-minute hiccups, but things were moving forward. The prison guards in Tehran rounded up the Americans, brought them to the warden’s office and told them to pack their belongings — their release was imminent. They should be ready to go home within three days.
But White House officials were about to receive some bad news. Just a day after the agreement was reached, they learned from the F.B.I. that Iran had seized another American citizen, a retired woman from California who was doing aid work in Afghanistan.
It was unclear then, and even now, whether the woman’s detention was a strategic decision or if she had simply gotten caught up in Iran’s web of security, a case of the country’s left hand not knowing what its right hand was doing.
Either way, the U.S. officials were livid. There was no way Mr. Biden could sign off on an agreement that would leave her behind. The woman from California had to be released, too.
The deal crumbled. And the prisoners, who by this point were expecting to go home any day, were crushed.
It would be weeks before U.S. officials, still working in secret, would get the talks back on track, with help from diplomats in Oman, Qatar and the United Arab Emirates.
When Mr. Biden finally announced on Monday that the Americans — including the newly captured woman — were on their way home, it was the culmination of years of careful negotiations focused not only on freeing the prisoners, but also on efforts to defuse tensions with Iran and counter what the U.S. views as Tehran’s destabilizing activities throughout the Middle East.
“When all the pieces finally come into place, there’s a collective sigh of relief, but up until that moment we’re all holding our breath,” said Jake Sullivan, the president’s national security adviser. “We don’t want the terrible ordeal these Americans are enduring to last a single day longer than it has to.”
The story of those negotiations was recounted by officials in the United States, Iran and Qatar; family members and lawyers for some of the prisoners; and representatives of other organizations familiar with the talks. Most spoke on the condition of anonymity to discuss confidential conversations about the prisoners.
The outcome, they said, is proof that even fierce adversaries can sometimes find their way to an agreement.
But it almost didn’t happen.
Nuclear talks stall
The work to bring home the Americans had begun early in 2021, just weeks after Mr. Biden took office.
Siamak Namazi, Emad Sharghi and Morad Tahbaz had been jailed on unsubstantiated charges of spying. They were held in Evin Prison, infamous for accusations of torture and a symbol of the regime’s authoritarian approach to justice.
Mr. Biden and his advisers were determined to get them out, somehow. For months, Secretary of State Antony J. Blinken carried the names of the detainees in his pocket.
First though, the United States and Iran needed to find ways to talk about broader issues. Throughout 2021 and the first half of 2022, Washington and Tehran hoped that they could revive the Obama-era nuclear deal, which had limited Iran’s nuclear program in return for sanctions relief. Former President Donald J. Trump had abandoned the deal.
Now, U.S. and Iranian officials were engaged in indirect talks in Vienna. And on a separate track, the Biden administration pushed for a way to free the imprisoned Americans.
But by August last year, those talks had completely broken down.
Iran was making demands about its nuclear program that the United States could not accept. It was rapidly increasing uranium enrichment to 20 percent, then 60 percent, stockpiling beyond levels approved in the now-defunct Obama deal. Iran’s top officials sided with Russia on its invasion of Ukraine, and reports surfaced of Iranian drones being sold to Russia and used to target civilians.
Behind the scenes, discussions about releasing the imprisoned Americans had become intertwined with the broader nuclear deal, known as the Joint Comprehensive Plan of Action.
To negotiators on both sides, it seemed clear that the United States would not approve a costly deal for the prisoners when the nuclear negotiations were falling apart.
“In the entire course of 2021 and for most of 2022, the U.S. seemed to prefer to wrap the detainee deal into the J.C.P.O.A.’s restoration,” said Ali Vaez, the Iran director of the International Crisis Group, who was familiar with the negotiations from both the American and Iranian sides. “It was only late last year, when the window closed on nuclear diplomacy, that a stand-alone detainee deal was contemplated.”
Iran wanted to be able to access $6 billion in oil revenue that was sitting in accounts in South Korea, virtually unusable because of currency issues. Iran’s negotiators demanded the money be moved in a way they could use it.
The United States was insisting that money would have to be placed in restricted accounts, with controls that made it impossible to use for anything other than food, medicine, medical devices or agriculture. The Iranians rejected the proposal outright.
A month later, in mid-September, nationwide protests erupted across Iran in the aftermath of Mahsa Amini’s death in the custody of the morality police. Iran’s government responded with brutal force, and scenes of young people being shot, killed, beaten and arrested dominated headlines about Iran.
Iranian forces also had intensified their attacks on American forces in Syria. Many in the Iranian American diaspora staged protests in cities across the United States and lobbied for Washington to end all negotiations with Iran and support Iranians fighting for democratic change.
And by this time, Iran had arrested a fourth American, a businessman and scientist whose identity has been withheld. The Biden administration continued to press for their release.
Robert Malley, who served as the Iran envoy for the United States, met several times with Amir Saeid Iravani, Iran’s ambassador to the United Nations. They were the only major face-to-face discussions between the United States and Iran about the prisoners, but they did not produce a breakthrough.
Mr. Iravani did not respond to questions from The New York Times about the talks.
The families of the American detainees and their lawyers publicly pressured Mr. Biden to set aside politics and bring their loved ones back home. Mr. Namazi, a 51-year-old businessman, gave an interview to CNN in March from Evin Prison saying that consecutive American presidents had left him behind to rot in an Iranian cell. He pleaded for help.
“I’ve been a hostage for seven and a half years — that’s six times the duration of the hostage crisis,” Mr. Namazi told CNN, referring to the Americans who were taken hostage in Iran during the 1979 revolution and held for 444 days.
But by the spring of this year, an agreement on anything that involved concessions to Iran seemed a million miles away.
Shuttle diplomacy resumes
The American diplomats arrived in Oman in May with a heavy dose of skepticism.
Iran had sent word, through intermediaries, that Tehran wanted to reduce tensions.
Just weeks earlier, Mr. Biden had ordered U.S. fighter jets to attack a munitions warehouse in eastern Syria linked to Iran’s intelligence services. His administration believed the attack, a direct response to Iran’s complicity in the first death of an American contractor in Syria in years, had rattled the Iranians. But the U.S. officials — including Brett McGurk, a veteran Middle East diplomat — were doubtful that Iran was serious.
Mr. McGurk and his American team huddled in one room of a hotel in Muscat, the capital of Oman. Iran’s delegation, led by a deputy foreign minister, Ali Bagheri Kani, gathered in another. For hours, Omani mediators shuttled back and forth between the two groups, who could see each other through windows.
The message from Mr. McGurk’s side was simple: If Iran wanted to reduce tensions, and perhaps even resume discussions about the country’s nuclear program, it had to stop attacking American forces. And it had to finally release the four Americans who were imprisoned, in some cases for years.
Through the windows, Mr. McGurk could see the Iranians arguing, a signal that there was hardly unanimity. But the messages returned by the Omani mediators contained a surprise. The Iranians wanted concessions about easing enforcement of sanctions on oil sales, but were willing to consider the U.S. demands for an exchange that would free the imprisoned Americans.
Within weeks, further talks were arranged in the nearby Gulf nation of Qatar, which had been trying for years to help broker the release of the Americans.
“Iran decided that if a nuclear deal with the U.S. was not tenable, it had to resolve its smaller problems such as the prisoner exchange and reducing the tensions in the region,” said Gheis Ghoreishi, a political analyst in Iran who has advised its foreign ministry. “The approach was if we untie a few of the knots eventually it could lead to a bigger opening, sanctions relief, a nuclear deal and such like.”
On June 6, with Qataris serving as the go-between in Doha, U.S. and Iranian officials hammered out a written agreement. The Americans would be released, and the United States would allow Iran to buy humanitarian goods using $6 billion of its profits from oil sales that had been stuck in banks in South Korea. The United States would also drop charges against five Iranians accused of violating American sanctions.
For Mr. McGurk and others in the White House and at the State Department, the flurry of diplomacy in Oman and Qatar in the spring of this year was a moment of hope.
Just maybe there was a chance to bring home the Americans after all.
One more delay
But the arrest of the fifth American, the California woman who was doing aid work in Afghanistan, upended any hopes of a quick solution.
For several weeks, Mr. McGurk and others in the United States tried to resurrect the agreement they had signed on June 6. Working through mediators again, the U.S. officials made it clear that the only way for the deal to proceed was if she were released too.
It took some time to “unstick” the situation, as one American official recalled. But once the Iranians agreed to the demand for the release of all five prisoners, negotiations reached a turning point.
In early August, following a visit to Tehran by Mohammed Al Khulaifi, a Qatari state minister, both sides came to a final agreement laying out the terms, including the prisoner exchange and the funds transfer mechanism. There were also stipulations that the funds would be held in Qatar and paid directly to vendors when Iran wanted to make humanitarian purchases on food, medicine and medical equipment.
On Aug. 10, all of the prisoners were transferred to a hotel in northern Tehran and placed under house arrest pending the complete transfer of the money.
Finally, on Monday, the Swiss ambassador in Tehran — known as the “protecting power in Iran” for the United States, which has no diplomatic presence there — drove two other American citizens to the airport. Iran had agreed to let Mr. Namazi’s mother, Effi, and Morad Tahbaz’s wife, Vida, leave on the same plane with their relatives. Both women had been prevented from leaving Iran since their family members’ detentions.
At the hotel where they were under house arrest, the five American prisoners were also ready to leave for the airport, where an airplane provided by Qatar’s government waited to take them to Doha for a Cold War-style swap on the tarmac and then a flight home.
But there was one more delay.
Officials in Iran claimed that not all of the money from South Korea had reached the bank account in Qatar. They would not let the Americans leave if the money could not be accounted for. For more than two hours, everyone just waited.
In New York, where the president and his aides had arrived for the upcoming United Nations General Assembly, national security officials were waiting anxiously. When Iranian officials confirmed that they were satisfied the money had arrived, the Americans boarded cars for the 40-minute drive to the Tehran airport.
At 5:30 a.m. on Tuesday, after a brief stop in Doha, the Americans walked off the plane at a military base in Northern Virginia, free for the first time since they were imprisoned.
Two hours later, Mr. Sullivan, the president’s national security adviser, posted a picture of the Americans gathered together in the small government plane.
Alongside an American flag emoji, he wrote: “Welcome home.”