US President Donald Trump on Saturday thanked Iran for its "very fair negotiations" after an exchange of prisoners between the two enemy countries.

"Have you seen, can we make an agreement together?" Trump also wrote on Twitter.

On Saturday, a Iranian arrested in the United States, Masoud Soleimani, and an American imprisoned in Iran, Shiwi Wang, were released in a rare cooperation between the two rival countries, whose relations worsened since the election of President Trump.

Trump said Xiu Wang, an American of Chinese origin, has been held in Iran for three years on charges of espionage back to the United States. An Iranian official also said that the Iranian Massoud Soleimani was released earlier in the United States.

A senior administration official said that Washington hoped the release of Wang would lead to the release of other Americans held in Iran, indicating that the move was an indication that Tehran was willing to negotiate other issues.

He added that Wang appeared to be in good health and with a sense of humor.

Switzerland has provided facilities for the exchange of prisoners, and the Iranian News Agency said that Foreign Minister Mohammad Javad Zarif received Suleimani in Zurich, which the agency said had witnessed the exchange.

The agency added that Soleimani will return to Iran in the coming hours.

In a statement issued by the White House, Trump did not mention the release of Soleimani, but thanked the Swiss government for its help in negotiating the release of Wang.

"My administration attaches great importance to the release of the captured Americans, and we will continue to work hard to return all of our citizens who are unjustly held outside the United States," Trump said.

Earlier, Zarif said an exchange was imminent. Later on, Twitter posted photos of him and Soleimani, traveling on an Iranian plane.

"I am glad that Professor Masoud Soleimani and Mr. Shi Yu Wang will return to their families soon," Zarif wrote on Twitter. We thank everyone involved in the matter, especially the Swiss embassy. ”

The Iranian news agency stated that Wang's release was based on "the rules of clemency of Islam."

The senior US official said the release of Wang was the fruit of three or four weeks of intense negotiations.

"We hope this will lead to more success with Iran," the official told reporters at a press conference.

"I hope that the release of Wang is an indication that the Iranians are aware that the method of hostage diplomacy should stop if Iran wants to return to the international community," he said.

The official added that President Donald Trump remains committed to conducting talks with Iran without conditions, noting that the maximum pressure campaign that America is executing against Iran is very successful and effective.