In a rare sign of co-operation between the US and Iran, the two countries have conducted a prisoner swap.
The exchange involved Chinese-American researcher Xiyue Wang, who was convicted of spying in Iran and Iranian scientist Massoud Soleimani, who was held by the US. Both men deny wrongdoing.
Iranian Foreign Minister Mohammad Javad Zarif said he was glad as he announced the exchange.
Hours later, President Donald Trump tweeted: “Thank you to Iran on a very fair negotiation. See, we can make a deal together!”
Xiyue Wang was arrested in Iran in 2016 for “collaborating with foreign governments”.
Massoud Soleimani, a stem cell expert, was arrested at a Chicago airport in 2018. He was accused violating trade sanctions by trying to export biological material to Iran.
The US and Iran have had an increasingly strained relationship in recent years and share no diplomatic links.
Both countries have thanked the Swiss government for its assistance as an intermediary facilitator.
Xiyue Wang was flown in a Swiss government plane from Tehran to Zurich, and then to Ramstein Air Base in Germany, where he will undergo medical check-ups before heading home.
Massoud Soleimani was also flown to Zurich and then on to Iran.
Mohammad Javad Zarif tweeted photos of himself with Massoud Soleimani after his release.
He was the first to announce the news, via Twitter: “Glad that Professor Massoud Soleimani and Mr. Xiyue Wang will be joining their families shortly.”
In a formal statement, President Donald Trump said Xiyue Wang had been “held under the pretence of espionage”.
The statement said: “Freeing Americans held captive is of vital importance to my Administration, and we will continue to work hard to bring home all our citizens wrongfully held captive overseas.”
Hua Qu, Mr
Xiyue Wang’s wife, Hua Qu, wrote in statement: “Our family is complete once again. Our son Shaofan and I have waited three long years for this day and it’s hard to express in words how excited we are to be reunited with Xiyue.
“We are thankful to everyone who helped make this happen.”
Princeton University, where Xiyue Wang was studying as a postgraduate, said in a statement it was “overjoyed” with the news of his release and was looking forward to “welcoming him back to campus”.
Xiyue Wang was arrested in Iran in August 2016 as he was leaving the country.
He had been doing research in Iran for a university dissertation and was accused of seeking to gather “highly confidential articles” for US and British academic institutions.
Xiyue Wang was sentenced to 10 years in jail for spying.
Massoud Soleimani was detained in October 2018 on accusations of attempting to export biological materials to Iran in violation of trade sanctions on the country over its nuclear program.
US-Iran tensions have risen significantly in the last two years.
After President Donald Trump took power, the US pulled out of a 2015 treaty that aimed to limit Tehran’s nuclear program.
Iran has always insisted its nuclear program is peaceful, but the US voiced concerns about potential weapon building.
President Donald Trump also reinstated sanctions on Iran, which have led to its currency plummeting and inflation soaring.