After a tense night filled with stops and starts, lawyers helping to win reporter Jason Rezaian’s release from an Iranian prison learned Sunday that their year-and-a-half- long effort had finally come to an end.

The Washington Post correspondent, who had been imprisoned for 544 days, was released along with four other Americans in a prisoner exchange involving seven Iranians held in the U.S. The deal unfolded amid easing diplomatic relations between the two countries, as the U.S. determined that Iran held up its end of a nuclear deal and lifted economic sanctions against the country.

The exchange was nearly halted at the last minute, however, when Rezaian’s wife and mother, who were both in Iran, were kept from the Swiss plane that was set to transport the Americans to Europe on Saturday.

“That was a harrowing 12-hour period,” said Wilmer Cutler Pickering Hale and Dorr partner David Bowker, one of Rezaian’s lead U.S. lawyers. The Washington Post hired Bowker and a Wilmer team led by senior counsel Robert Kimmitt to help free Rezaian in July 2014, shortly after the Tehran-based correspondent and his wife were arrested.

Wilmer’s Kimmitt, co-chair of the firm’s strategic response group and a former U.S. ambassador to Germany, represented The Washington Post in a similar matter in 2009, when the newspaper owned Newsweek. At that time, Kimmitt worked on the case of Maziar Bahari, a Newsweek reporter who was detained in Iran and whose story inspired the Jon Stewart film “Rosewater.”

Bowker said the eleventh-hour crisis involving Rezaian’s family members threatened to derail the delicate prisoner swap. “We just had really grave concerns that they were going to make Jason decide whether to leave without them,” he said. But in the end, according to The Washington Post, U.S. Secretary of State John Kerry interceded with Iran’s foreign minister, Mohammad Javad Zarif, and Rezaian’s wife and mother were allowed to board the plane.

By Tuesday, Rezaian was in Germany seeking medical care. Americans Saheed Abedini, a Christian pastor, former U.S. Marine sergeant Amir Hekmati, Matthew Trevithick and Nosratollah Khosravi-Roodsari were also released in the exchange.

For Wilmer and other American law firms working for those held in the U.S. and Iran, the weekend’s events marked the culmination of a sustained effort. For Wilmer, it entailed a global public relations, lobbying and legal campaign that reached close to 40 foreign governments and international organizations, including the United Nations.

Bowker said the Wilmer team had to balance its efforts to keep Rezaian in the public eye with a fear that he could be punished by Iranian officials for the attention he received.

“We had well-founded concerns that there could be retaliation for our efforts, so we had to be sure to always be thinking about Jason’s health and safety and not do anything that put him in further jeopardy,” Bowker said. At the same time, the lawyers held press conferences and lobbied Congress and foreign officials to “show that we were not going away until he was free,” Bowker said.

The firm also filed a petition for Rezaian’s release with the U.N. Working Group on Arbitrary Detention, which was presented before the Human Rights Council in Geneva. Bowker said that in response, the U.N. group granted the petition and notified Iran that Rezaian’s fundamental human rights had been violated under international law.

Bowker said he was grateful to staff at the U.N. who worked on the case.

“Those institutions and individuals gave us a legal platform and venue to advance the case and to highlight for the world the rule of law issues and the legal violations that Iran had caused Jason to suffer,” he said. “The Iranians take that U.N. venue quite seriously.”

Rezaian was represented in Iran by Leila Ahsan, who was given limited access to her client, according to testimony presented to the U.S. House of Representatives Committee on Foreign Affairs by Rezaian’s bother, Ali Rezaian.

Rezaian’s counsel weren’t the only U.S. lawyers celebrating the prisoner exchange on Sunday.

Quinn, Emanuel, Urquhart & Sullivan partner David Gerger was notified by the Justice Department that his client Khosrow Afghahi would be involved in a prisoner swap. Gerger said he went to the jail at 5 a.m. Saturday morning, but it took 23 hours before Afghahi was freed along with six other Iranians as part of the weekend’s deal. Afghahi had faced charges of violating the Iranian embargo in the Southern District of Texas.

“Right now he is spending precious time with his family,” Gerger said of his client, who has dual citizenship in the U.S. and Iran. “He is a 72-year-old businessman who has never been in trouble. This was a very difficult ordeal, and we are happy to put it behind him.”

Joel Androphy, name partner at Berg & Androphy, represented released Iranian prisoner Bahram Mechanic, who was also charged in Texas for violating the embargo. Androphy said once he learned Friday that Mechanic had been pardoned by President Barak Obama, he knew it was only was a matter of time before he’d be released.

“He was innocent from day one,” Androphy said of Mechanic. Androphy had been pursuing a visa to go to Iran to obtain documentation that Mechanic was blacklisted by the Iranian government, hoping that would prove he could not have been an agent of Iran, the lawyer said. Though the case is finished, Androphy said he still hopes to travel to Iran as a tourist.

Nader Modanlo, another released Iranian prisoner, was also pardoned after being charged with violating the Iranian embargo. Modanlo was represented by Mayer Brown partner Daniel Himmelfarb.