The largest prisoner exchange with Russia since the Cold War took months of detailed negotiations that directly involved the president, government officials told ABC News.
The deal, which freed Wall Street Journal reporter Evan Gershkovich and former U.S. Marine Paul Whelan, involved several nations and included key exchanges by President Joe Biden, according to the officials. The deal also freed Alsu Kurmasheva, a Russian-American journalist, and Vladimir Kara-Muza, a legal permanent resident of the U.S.
"In the context of the war against Ukraine and the overall degradation of our relations with Russia, securing the release of Americans detained in Russia has been uniquely challenging," White House National Security Advisor Jake Sullivan said Thursday.
Biden said at a press conference on Thursday, "If anyone questions if allies matter, they do, they matter."
Even on the day he announced he was no longer seeking re-election, Biden, who was recovering from COVID-19, was on the phone working to secure this deal, a senior administration official told ABC News.
MORE: Why were Evan Gershkovich, Paul Whelan and others being held prisoner in Russia?"The hour before he released that statement – literally an hour before he released that statement – he was on the phone with his Slovenian counterpart urging them to make the final arrangements and get this deal over the finish line," the official said.
"This exchange is not by accident. It really is the result of a heck of a lot of leadership by President Biden and by the strength of relationships," a senior administration official said.
Sullivan revealed Thursday that the U.S. and its allies were working on a prisoner deal that would have included the release of Russian opposition leader Alexei Navalny, who was arrested by Russian officials in 2021.
Russian authorities announced Feb. 16 that Navalny had died while in prison.
The U.S. negotiation team "felt like the wind had been taken out of our sails in terms of efforts to get Paul and Evan back home," upon learning of Navalny's death, a senior administration official told ABC News.
MORE: Timeline of Alexei Navalny’s life and activismBut Sullivan, who happened to have a meeting scheduled with Evan's family that day, felt differently, according to the official.
"He still saw a path forward, he thought it was going to be a little bit more of a rocky path, and it might take us a little bit longer than we thought," the official said.
"He gathered the team together and he told him to not let Navalny's death totally torpedo our opportunities to get these folks out," the official said. "And he instructed them to come up with some additional options to make it politically viable, particularly politically viable to the Germans."
One key sticking point, according to Sullivan, was that Russia "would not agree to the release of these individuals without an exchange that included Vadim Krasikov," who was in German custody for allegedly gunning down a Kremlin opponent in Germany.
"That required extensive diplomatic engagement with our German counterparts, starting at the top with the President himself, who worked this issue directly with Chancellor [Olaf] Scholz. We are deeply grateful to Germany for their partnership," Sullivan said.
To get the German's on board, a senior administration official credited not only Sullivan's work to get a proposal in place, but also Biden's relationship with German Chancellor Scholz.
"All culminated, really, in a call by President Biden to Chancellor Scholz, and then a follow-on visit by Chancellor Scholz in February, where, basically, Chancellor Scholz responded to the president saying, 'For you, I will do this.' The president then turned to Jake and said, Get it done,'" the official said.
The administration official stressed that "nobody's turning a blind eye" to the crimes of Krasikov, or his connection to Russian intelligence service, but said "tough decisions" needed to me made to get these four innocent people back home and to their families.
There should be no expectation of improved U.S.-Russia relations going forward, according to a senior administration official.
This official said the administration has shown it can hold Russia accountable for its aggression on the world stage while "compartmentalizing out" the work on securing the release of Americans that are wrongfully detained.
MORE: Biden celebrates freeing of Americans wrongfully detained in Russia: 'Their agony is over'"I would be cautious and would counsel anyone to be cautious in surmising from this that it's some sort of breakthrough in the relationship and it portends some détente with Russia or an easing of the tensions in our relationship."
This official said Russia's ongoing war against Ukraine, pressure on NATO allies and across Europe, and the "burgeoning defense relationship" Putin is forming with China, North Korea and Iran are "of significant concern."
"We will not see a policy change by President Biden and the administration when it comes to standing up to Putin's aggression."
ABC News' Ivan Pereira contributed to this report.