London -- An American graduate student who was jailed for more than three years in Iran is headed home after a prisoner swap.
Xiyue Wang, 38, a Princeton University student, was exchanged for Iranian scientist Professor Massoud Soleimani early on Saturday as part of a prisoner exchange brokered by the Switzerland government. Wang had been held in Iran's notorious Evin prison since August 2016 on charges of espionage.
President Trump said Wang had been held under the "pretense" of espionage."
"The highest priority of the United States is the safety and well-being of its citizens," the president said in a statement. "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.”
A senior administration official said Switzerland had been negotiating for Wang's release for more than three weeks. Wang, who is currently in Germany, is in good spirits, the official said.
Wang, who is married with a son, was a Eurasian history scholar. He traveled to Iran in 2016 to study Persian and conduct research for his dissertation.
Before traveling, Wang wrote to the Iranian Interest Section at the Pakistani embassy in Washington, D.C., which issued his visa. He also wrote to the libraries in Iran he planned to visit, according to Princeton University.
He was transparent about what he wanted to study and why, according to the university, and about his desire to access documents housed at Iranian libraries and archives.
“He was not involved in any political activities or social activism; he was simply a scholar trying to gain access to materials he needed for his dissertation,” the school said in a statement about his case.
Wang's wife, Hua Qu, tweeted that their family was "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 tweet read. "We are thankful to everyone who helped make this happen."
In exchange for Wang's release, Professor Massoud Soleimani, who was arrested at a Chicago airport last year and charged with violating trade sanctions against Iran, was headed home, too.
A stem cell researcher who had been working in Minnesota, Soleimani was charged after he was reportedly seeking to transfer biological material back to Iran without a license.
His lawyers argued that he was innocent, saying the sanctions law was ambiguous.
Javad Zarif, Iran's foreign minister, was there to greet him at the airport; he flew with Wang from Tehran to Switzerland.
In a tweet, Zarif said: “Glad that Professor Massoud Soleimani and Mr. Xiyue Wang will be joining their families shortly. Many thanks to all engaged, particularly the Swiss Government.”
ABC News' Elizabeth Thomas contributed to this report.