Oren Dorell and Doug Stanglin

USA TODAY

Jason Rezaian, The Washington Post reporter held in an Iranian prison for almost 18 months on spy charges, and four other Americans "unjustly detained" by Iran were freed Saturday only hours ahead of the formal lifting of international sanctions on Tehran under terms of a nuclear agreement.

Iran also agreed to allow Rezaian’s wife, Yeganeh Salehi, who is an Iranian citizen, to leave the country with him, U.S. officials said, The Washington Post reported. She is a correspondent for The National, a newspaper based in the United Arab Emirates.

In Vienna, Secretary of State John Kerry made the announcement of the prisoner releases official only moments after a U.N. watchdog group certified Iran's compliance with the nuclear deal.

While the nuclear and prisoner issues were not formally linked, Kerry made it clear that diplomatic moves on one front spurred progress on the other.

"While the tracks of negotiations were not directly related, there is no question that the pace and progress of the humanitarian talk accelerated in light of the relations forged and diplomatic channels unlocked over the course of the nuclear talks," Kerry said. "And certainly in the time since we reached an agreement last July, there was significant pickup in that dialogue."

Five freed in total

In addition to Rezaian, Amir Hekmati, Pastor Saeed Abedini and Nosratollah Khosravi-Roodsari were also freed, as well as an fifth American whose release was not formally part of the prisoner swap.

"I am very happy to say that as we speak, we have received confirmation that five Americans who had been unjustly detained in Iran have been released from custody and should be on their way home to their family shortly," Kerry told reporters.

The four Americans have not yet left Iran. The Swiss government, which has been helping to coordinate the release in the absence of a U.S. embassy in Tehran, is still working to get them to the Tehran airport, said two U.S. officials who spoke on condition of anonymity because of the sensitivity of the not-yet-completed transfer.

The officials said they would ensure the Americans were in good health and reunited with their families, but declined to discuss further logistics of the transfer because of privacy concerns.

Matthew Trevithick, the fifth American citizen released by Iran in what U.S. officials called a “goodwill gesture,” has already left the country.

Iranians pardoned

As part of the deal, Obama also agreed to pardon or commute the sentences of seven Iranians held by the United States, a senior U.S. official said on condition of anonymity because the president had not yet signed the pardon paperwork.

The administration has not identified the Iranians who will be granted clemency under the president’s constitutional pardon power. None have been charged or convicted of any terrorism-related or violent crimes, the official said, but were instead charged or convicted of crimes related to the evasion of Iranian sanctions. Six of them hold dual Iranian and American citizenship, and the seventh is an Iranian.

The Islamic Republic News Agency identified the seven being freed from U.S. jails as Nader Modanlo, Bahram Mechanic, Khosrow Afghani, Arash Ghahreman, Tooraj Faridi, Nima Golestaneh and Ali Saboun.

The United States also agreed to release a number of Interpol “red notices” on Iranians wanted for crimes in the United States but not in U.S. custody, the official said.

Earlier, an unnamed U.S. official said in an email from the State Department that the U.S. had also agreed to drop efforts to seek the extradition of 14 Iranians on unspecified charges. Iranian officials said the 14 were being sought for alleged involvement in the purchase of arms from the U.S. to Iran.

In addition, the official said Iran had committed to continue cooperating with the United States to determine the whereabouts of Robert Levinson, an American who disappeared in Iran in 2007 while working for the CIA on an unapproved intelligence mission. U.S. officials are unsure if the former FBI agent is even still alive. Iranian officials have denied knowing his whereabouts.

Families waiting

“We couldn’t be happier to hear the news that Jason Rezaian has been released from Evin Prison," Frederick J. Ryan, Jr., publisher of The Washington Post, said in a statement. "Once we receive more details and can confirm Jason has safely left Iran, we will have more to share.”

Rezaian, Hekmati, Saeed Abedini and Khosravi-Roodsari were to be flown from Iran to Switzerland aboard a Swiss aircraft and then transported to a U.S. military hospital in Landstuhl, Germany, for medical treatment, U.S. officials told the Associated Press.

Hekmati, a retired Marine from Flint, Mich., was detained in August 2011 on espionage charges. He was sentenced to death in 2012. After a higher court ordered a retrial, he was sentenced in 2014 to 10 years.

Hekmati’s lawyer, Mahmoud Alizadeh Tabatabaei, said Hekmati called him earlier Saturday from prison, AP reported. “He told me that judiciary officials have called for a meeting with him. But I’ve not been formally informed if he is free now,” he said, adding negotiations for the prisoners’ release has been going on for the past two months.

Abedini of Boise, Idaho, was detained for compromising national security, presumably because of Christian proselytizing, in September 2012. He was sentenced in 2013 to 8 years in prison. Abedini was previously arrested in 2009 and released after promising to stop organizing churches in homes. At time of arrest, was running an orphanage in Iran.

Naghmeh Abedini, the pastor's wife, said, "This has been an answer to prayer."

"This is a critical time for me and my family," she said in a statement, according to CNN. "We look forward to Saeed's return and want to thank the millions of people who have stood with us in prayer during this most difficult time."

"We thank everyone for your thoughts during this time," the Hekmati family said on Twitter. "There are still many unknowns. At this point, we are hoping and praying for Amir's long-awaited return."

The announcement coincided with Kerry's arrival in Vienna to meet Iranian Foreign Minister Mohammad Javad Zarif to finalize the lifting of the sanctions, starting with the freeing up of some of the $100 billion in frozen Iranian assets. President Obama released an executive order lifting the sanctions Saturday afternoon.

Obama signs executive order revoking Iran nuclear sanctions

“This is also a good day for the world,” Zarif said upon arrival in Vienna ahead of the announcement. “Today is a day when we prove to the world that threats, sanctions, intimidation, pressure don’t work; respect works.”

“Through respect, through dialog, through negotiations, we can in fact reach mutually-acceptable solutions, implement mutually acceptable solutions, prove that the nay-sayers were always wrong, and therefore move towards a world in which diplomacy – not force, not pressure – will prevail,” he said.

'Washington Post' reporter languishes in Iranian jail

The latest developments also come three days after intense diplomatic activity between U.S. and Iran over the detention of 10 U.S. Navy sailors and their two boats in the Persian Gulf. The sailors were freed in less than 24 hours after Kerry intervened with Zarif in multiple telephone calls that administration officials hailed as a channel of communication opened because of the nuclear negotiations.

Critics, however, bristled at Iran airing video of the sailors being forced to their knees as they were being detained. U.S. officials said the sailors drifted into Iranian waters because of a navigational error.

Contributing: Gregory Korte in Washington; Roger Yu, in McLean, Va.