The prisoner exchange between the U.S. and Iran capped 14 months of secret diplomacy and talks between Washington and Tehran as the U.S. and world powers negotiated the pact to curb Iran’s nuclear program, reflecting a thaw in relations between the sworn enemies. The negotiation over the prisoners began on the sideline of the nuclear talks, intensified after the deal was completed last April and heated up even further in recent months, senior administration officials told CNN. The secret talks were led by Brett McGurk, the U.S. special envoy tapped by President Barack Obama to coordinate the global fight against ISIS, the officials said. The U.S. government confirmed Saturday that Iran freed four Americans as part of a prisoner swap for which the U.S. is dropping charges against seven Iranians who had been convicted in the U.S. for sanctions violations, the officials said. Washington Post reporter Jason Rezaian, former Marine Amir Hekmati, pastor Saeed Abedini and Nosratollah Khosravi-Roodsari were released from Iranian custody, the officials said. Not much is known about Khosravi-Roodsari. A fifth American, Matthew Trevithick, is also being released by Iran, U.S. officials said, but they said his release was not part of the negotiated prisoner swap. Senior administration officials said Trevithick was recently detained in Iran. The Iranians were not convicted of violent crimes but of violating the sanctions ban against Iran, according to the officials. The names of the Iranians have not yet been released, the officials said, adding that the four Americans had not left Iran as of late Saturday morning. A U.S. official, speaking on background in a press release issued by the State Department, said the seven Iranians have dual citizenship with the U.S. and are convicted or are pending trial in the United States. The U.S. has “also removed any Interpol red notices and dismissed any charges against 14 Iranians for whom it was assessed that extradition requests were unlikely to be successful.” The Iranians told the U.S. during the talks they wanted a “goodwill gesture” and gave the U.S. a list of Iranians they wanted released. The U.S. officials excluded any names of anyone charged with terrorism or violence, insisting that they would only consider those who had been convicted of sanctions violations or violations of the trade embargo. After every meeting on the nuclear deal between world powers and Iran, the U.S. insisted there had to be a separate session between the U.S. and Iran on the American prisoners, the officials said. U.S. officials, however, said this does not set a precedent. “This is a unique arrangement,” one U.S. official said. “This is a humanitarian gesture.” A senior administration official who briefed reporters said a “window” opened after the Iranian nuclear deal “and we wanted to take advantage of that window.” Sailors didn’t interfere with prisoner negotiations The Obama administration has been criticized by several Republican presidential candidates, including GOP front-runner Donald Trump, for reaching the nuclear deal with Iran while the Americans remained imprisoned. The swap also comes days after Iran briefly detained 10 U.S. sailors who drifted inadvertently into Iranian waters. The sailors were promptly released after a flurry of diplomacy between Secretary of State John Kerry and Iran’s foreign minister, Mohammad Javad Zarif. Asked whether the sailors’ detention complicated the prisoner exchange, a senior U.S. official said “it didn’t at all,” suggesting that the “budding relationship” between Washington and Tehran helped resolve both matters. “In fact, it’s just the opposite,” the official said. “When this happened, we were worried (the prisoner exchange) wouldn’t get done and we wouldn’t get the Americans back, but Secretary Kerry and Foreign Minister Zarif, who have a good relationship, quickly began talking and both agreed that the sailors could pose a distraction that could jeopardize the deal and so they got it cleared up very quickly.” When news first broke of the incident involving the sailors, tensions were high, the official said. But the way it was quickly resolved allowed the parties to return to wrapping up negotiations on the prisoners. Nuclear deal helped pave way for release Rezaian, a dual Iranian-American citizen, has been held in Iran for more than a year after being arrested and charged with “espionage and other offenses.” After a closed-door trial, Iranian state media reported in October that he was found guilty. An Iranian court sentenced him to prison in November, but the length of the sentence was not specified. Rezaian’s family and The Washington Post have maintained his innocence and repeatedly called for his release. Iran also detained, but later released, Rezaian’s wife, Yeganeh Salehi, but has barred her from leaving the country. She is expected to fly out of the country with her husband. Iran had initially insisted Jason Rezaian’s fate could only be decided by Tehran’s judicial system rather than through political accommodation with the U.S. But the nuclear deal, reached last year, held out hope for increased dialogue about Rezaian and the other Americans. Last week, an Iranian judiciary spokesman said the U.S. had contacted Iran for a deal to swap Rezaian for unspecified Iranian detainees, but U.S. officials declined to comment, saying any talk could jeopardize efforts to bring the Americans home. Iranian President Hassan Rouhani has said publicly that he would be open to such an idea. In September, he told CNN’s Christiane Amanpour his country would be inclined to release American prisoners, including Rezaian, if the U.S. released Iranians it is holding. “If the Americans take the appropriate steps and set them free, certainly the right environment will be open and the right circumstances will be created for us to do everything within our power and our purview to bring about the swiftest freedom for the Americans held in Iran as well,” Rouhani said. Rouhani said through an interpreter that anytime something can be done to help someone in prison, “nothing would make me happier.” Because Iran has reached a landmark nuclear agreement with world powers, Rouhani said in September, there is no reason for the U.S. to hold prisoners who were arrested for violating the sanctions that are now being lifted. “There are a number of Iranians in the United States who are imprisoned, who went to prison as a result of activities related to the nuclear industry in Iran,” he said through an interpreter. “Once these sanctions have been lifted, why keep those folks in American prisons?” he said. “So they must be freed.” Rouhani said that “consular issues” had been discussed on the sidelines of the nuclear negotiations, and that it would not be unusual for those talks to now continue. “If the Americans take the appropriate actions vis-a-vis Iranian citizens who are being imprisoned here, then the right atmosphere and environment will be created for reciprocal action, perhaps.” Also in September, Kerry acknowledged for the first time in an interview with CNN that the U.S. was holding talks with Iran that could include a possible prisoner swap, but he declined to provide details of the discussions. “I have raised them in all of our sessions. We’ve had a lot of conversations. We are continuing those conversations now. And I am hopeful that the day will come soon, obviously sooner rather than later, but soon, when all of our citizens can come home,” Kerry said. Saturday afternoon, Kerry told reporters in Vienna that the prisoner swap was “accelerated” by the nuclear agreement. American contractor not among those freed Hekmati was detained in 2011, shortly before he was scheduled to leave Iran after visiting family. He was sentenced to death on the charge of working for an enemy country. The sentence was eventually overturned, but he remained in prison. He later confessed on state TV to working for the CIA but then retracted the confession in a letter to Kerry, claiming it was obtained by force. Abedini, an Iran-born pastor, was arrested in 2012 on charges related to his conversion to Christianity and involvement with Iranian churches. American Robert Levinson, a former FBI agent and contractor for the CIA, who vanished after visiting Iran in 2007, was not among the Americans released. Iranian officials have denied any knowledge of his whereabouts, but the senior administration officials have been told that they have an agreement with the Iranians that they will seek information about him. “Iran has also committed to continue cooperating with the United States to determine the whereabouts of Robert Levinson,” a U.S. official said. The U.S. has said it will not give up on the case of a separate American being held in Iran, Siamik Namazi.