President Joe Biden's decision to make a risky wartime visit to Kyiv took root after a similarly clandestine mission just two months ago — when Ukrainian President Volodymyr Zelenskyy came to Washington and addressed a joint meeting of Congress, according to two sources familiar with the matter.
Senior members of Biden's national security team who helped arrange the travel at the end of last year were heartened — and pleasantly surprised — by how powerful and positive the reaction to Zelenskyy's trip seemed to be among the American people, said the sources, who, like others in this article, were granted anonymity to discuss internal planning. It was Zelenskyy's first travel outside Ukraine since the start of the war.
Hoping to sustain momentum for efforts to keep the fragile Western alliance together in support of Ukraine, the officials began discussions about using the anniversary of Russia's invasion to make a similarly bold gesture.
Publicly, the planning would play out in the trip officials formally announced 10 days ago — that Biden would make a second trip to Poland, Ukraine's neighbor, to meet with its president and other NATO allies who have most to lose from any weakening of Western resolve.
But privately, among a small universe of senior officials, the thinking was that this might be the moment to realize a long-held hope among some officials for an even more potent demonstration of U.S. solidarity: having Biden visit Ukraine.
"Discussions about possibly going have been underway for months and really accelerated in recent weeks," a senior administration official said.
Officials across the government had long made it clear that it was nearly impossible to guarantee Biden's safety heading into a war zone in which the U.S. is not an active partner.
More from NBC News:
Rights groups threaten to sue Biden administration over plan to block migrants with what groups call a Trump-era tactic
Biden's foray into Ukraine deepens his investment in defeating Russia
U.S. ambassador to U.N. warns China would be crossing a 'red line' if it provides lethal aid to Russia
Other leaders of NATO and the G-7 group of major industrial nations, senior members of Congress and the secretaries of defense and state had all made the long, secretive journey to Kyiv. First lady Jill Biden made a surprise Mother's Day visit to western Ukraine, spending two hours in the border town of Uzhhorod to meet first lady Olena Zelenska.
But the level of security needed for the president of the U.S. had long been considered incompatible. Even until the end, discussions about security measures were "intense," as another official put it. They even included a call to Russian officials hours before Biden departed for "deconfliction" purposes, national security adviser Jake Sullivan would later tell reporters.
"[It] required a security, operational and logistical effort from professionals across the U.S. government to take what was an inherently risky undertaking and make it a manageable level of risk," Sullivan told reporters after Biden left Kyiv on Monday afternoon local time. "But, of course, there was still risk and is still risk in an endeavor like this."
Biden spent about five hours in the capital, meeting with Zelenskyy and other Ukrainian officials. The two leaders visited St. Michael's Golden-Domed Monastery and then walked to the nearby Wall of Remembrance, which honors those who have died in the war.
Sullivan and his deputy, Jon Finer, said that while planning involved officials from across the government, it was a very closely held among every agency involved.
At a White House news briefing Friday, National Security Council spokesperson John Kirby flatly denied that Biden would detour to Ukraine on his Poland trip.
Typically, it would be Sullivan who briefed reporters ahead of a Biden foreign trip, but he did not this time so he would not be in the position of misleading reporters, two sources familiar with the matter said.
As planning reached the late stages, aides to Vice President Kamala Harris were told that her itinerary for the Munich Security Conference needed to be trimmed to ensure that she returned to U.S. soil by Saturday night. They were not given a reason, only that it was "nonnegotiable," according another administration officials.
On Sunday, the White House released a public schedule that had Biden scheduled to depart for Poland late Monday — well after he had already quietly left Washington.
Instead, a handful of officials gathered at the White House before dawn, along with others in Europe, to track his journey every step of the way, two officials said.
Sullivan was among the small number of staff members who traveled with Biden on Monday; others who were due to travel to Poland will still travel, without Biden, as scheduled Monday night.
White House officials did not immediately provide additional details of the precautions taken to minimize the security risks. But one obvious hurdle was how to provide security without committing U.S. air assets in the region.
Biden took a 10-hour train ride from the Polish border into Kyiv. A source familiar with the matter said that while Biden could have gone to other locations in Ukraine that would have been easier to reach, he chose Kyiv to highlight that the capital is still standing after Ukraine's forces proved to Russian President Vladimir Putin that the country would be more different to topple than anticipated.
For Jill Biden's visit to Ukraine in May, military aircraft tracked her motorcade as it made its way from a Slovakian airport up to the border but did not follow along as she drove across Ukraine's border. The first lady's trip was made public only as she prepared to cross back into Slovakia hours later.
When Joe Biden, then the vice president, last traveled into a war zone, a trip to Baghdad and Erbil, Iraq, in April 2016, his arrival was disclosed after he had safely arrived in the Green Zone, with subsequent movements covered by the traveling media pool.
Biden noted that Monday's trip was his eighth to Ukraine, and his first words after he stepped off the train were, "It's good to be back in Kyiv," according to the media pool.
Biden last visited the country in his final days as vice president.
This time, he "was very focused on making sure that he made the most of his time on the ground, which he knew was going to be limited," Sullivan said.