An American graduate student held in Iran has been released in exchange for an Iranian scientist held by the U.S., officials confirmed.

Iran’s foreign minister and the White House both announced that Princeton University graduate student Xiyue Wang was exchanged for scientist Massoud Soleimani.

Brian Hook, the U.S. special representative for Iran, accompanied the Iranian scientist to Switzerland to make the exchange and will return with Wang, a U.S. official told The Associated Press on condition of anonymity. The swap took place in Zurich and Hook and Wang are now en route to Landstuhl in Germany where Wang will be examined by doctors, the official said. Hook is expected to return to the U.S. from Germany alone, as Wang is expected to be evaluated for several days.

In his opening remarks at the Reagan National Defense Forum on Saturday night, National Security Adviser Robert O’Brien announced that Wang will be coming home from a U.S. military hospital in Germany in the “next day or two.”

“After more than three years of being held prisoner in Iran, Xiyue Wang is returning to the United States,” President Trump said in a statement released by the White House on Saturday. “The highest priority of the United States is the safety and well-being of its citizens. 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.”

Secretary of State Mike Pompeo said Saturday that Wang was on his way back to the United States, where he will soon be reunited with his wife and son.

"The United States will not rest until we bring every American detained in Iran and around the world back home to their loved ones," he said in a statement.

Officials told Fox News that doctors were examining Wang in Germany before he flys to the U.S.

WIFE OF US SCHOLAR IMPRISONED IN IRAN SPEAKS OUT: 'HIS ONLY CRIME IS HE'S AMERICAN'

Wang was sentenced to 10 years in prison for allegedly “infiltrating” the country and sending confidential material abroad. His family and Princeton University strongly denied the claims.

According to the university, Wang was arrested while conducting research on the Qajar dynasty that once ruled Iran for his doctorate in late 19th and early 20th century Eurasian history.

His wife, Gua Qu, rejoiced over the news of his release in a statement on Twitter.

“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,” the statement said. “We are thankful to everyone who helped make this happen.”

Wang’s release was negotiated with the assistance of the Swiss Embassy in Tehran, who looks out for America’s interests in the country as the U.S. Embassy there has been closed since the 1979 student takeover and 444-day hostage crisis.

Iran’s state-run IRNA news agency reported that Soleimani was with Iranian officials in Switzerland.

PENTAGON MULLS SENDING UP TO 7,000 ADDITIONAL FORCES TO MIDDLE EAST, OFFICIALS SAY

Soleimani — who works in stem cell research, hematology and regenerative medicine - was arrested by U.S. authorities on charges he had violated trade sanctions by trying to have biological material brought to Iran.

He and his lawyers maintain his innocence, saying he seized on a former student’s plans to travel from the U.S. to Iran in September 2016 as a chance to get recombinant proteins used in his research for a fraction of the price he’d pay at home.

"Glad that Professor Massoud Soleimani and Mr. Xiyue Wang will be joining their families shortly. Many thanks to all engaged, particularly the Swiss government," Iranian Foreign Minister Mohammad Javad Zarif said in a tweet.

US WANTS INFO ON IRANIAN PLANNER OF 2007 ATTACK THAT KILLED 5 US TROOPS, OFFERS $15M

Wang is one of at least four known Americans being held prisoner in Iran, all accused of spying.

The family former FBI agent Robert Levinson, the most notable detention of an American in Iran, told Fox News in a statement that they welcomed Wang's release, but that the news was "bittersweet" for their family.

"We can't help but be extremely disappointed that, despite all its efforts, the United States government was unable to secure his release as well, especially after such a painful week for our family," the statement. "Iranian authorities continue to play a cruel game with our father's life, and with our family. But the world knows the truth, and Iranian leadership must come clean. It is time for Iran to send Bob Levinson home, so he can live the rest of his life in peace. We look forward to when that day will come."

The family of Baquer and Siamak Namazi, a father and son who are serving a 10-year sentenced for allegedly collaborating with a hostile power, reiterated the sentiments, saying they were thrilled that Wang's "horrific nightmare" has ended.

"I am beyond devastated that a second President has left my ailing father Baquer Namazi and brother Siamak Namazi behind as American hostages in Iran in a second swap deal," said Babak Nazami, the pair's son and brother. "I hope, pray and expect that this is not a one-time trade but the beginning of an expedited process that will bring my family home soon."

Iran has detained dual Iranian nationals and those with Western ties in the past to be used as bargaining chips in negotiations.

CLICK HERE TO GET THE FOX NEWS APP

Tensions have been high between Iran and the U.S. since President Donald Trump unilaterally withdrew America from Tehran's nuclear deal with world powers in May 2018. In the time since, the U.S. has imposed harsh sanctions on Iran's economy. There also have been a series of attacks across the Mideast that the U.S. blames on Iran.

The Associated Press contributed to this report.