In late December, a group of North Korean teenagers travelled to Kunjming, China, for an under-15 soccer tournament. They faced teams from China and South Korea. Off the field, there was an unusual spectator: Choi Moon-soon, governor of the province in South Korea hosting the Winter Olympics.
Choi had flown there to meet the North Korean officials accompanying the young players - and to make the case for North Korea to attend the Olympics. "We were looking for any contact with North Korea, and the youth soccer teams were the only inter-Korean exchange still going on," he recalled.
Even before Choi returned to South Korea, his government sent another signal: in a television interview, President Moon Jae-in said he favoured postponing annual joint military exercises with the United States - an unmistakable overture to North Korea's leader, Kim Jong Un, who had long condemned the exercises.
Kim soon reciprocated, declaring at the start of the year that he was sending his athletes to the Olympics. There, they marched in the opening ceremony on Friday under a unified Korean flag with the South Koreans - a historic moment for the divided Korean Peninsula.
The eleventh-hour accommodation was the culmination of months of behind-the-scenes diplomacy aimed at persuading North Korea to attend the Olympics, much of which unfolded even as the isolated nation tested its first intercontinental ballistic missiles and detonated its most powerful nuclear device yet.
With President Donald Trump threatening to respond to the North with "fire and fury," the possibility of war on the Korean Peninsula overshadowed Olympic preparations, frightening fans and athletes alike, and prompting some nations to consider skipping the games. But the International Olympic Committee and South Korea pressed ahead. It was too late to move the games, and cancellation was unthinkable.
The best hope for success, organisers concluded, was to persuade North Korea to participate. If the North came to the games, it seemed more likely to exercise restraint and refrain from the missile launches and nuclear tests that had rattled the world. Some, including Moon, argued that the Olympics could even be the start of talks to resolve the nuclear crisis.
But getting North Korea to attend the games was a diplomatic puzzle amid escalating tensions. Those interested in a successful Olympics confronted a challenge similar to what diplomats trying to defuse the nuclear crisis had grappled with for years: Kim calls all the shots in North Korea, but no one knows what he wants and there are few channels for communicating with him.
Thomas Bach, now IOC president, did not want
the Olympics in the South Korean resort of Pyeongchang. As South Korean officials promoted
their country, Bach, then president of the German
Olympic Sports Confederation, had lobbied for Munich to host the 2018 Winter Games.
But South Korea won the bid by turning a potential liability - Pyeongchang's proximity to the world's most heavily armed border - into a selling point. Recalling the Olympic truce of the ancient Greeks, officials proposed "Peace Games" to promote reconciliation on the Korean Peninsula. Now, Bach had to make them a success.
At the 2016 Summer Games in Rio de Janeiro, he met North Korean officials and outlined possible financial and logistical support to bring the North's athletes to Pyeongchang without violating UN sanctions, according to the Olympic committee. And last February, the committee sent North Korea a formal invitation. But the North demurred.
Bach sought help from South Korea, meeting at least three times with Moon's conservative predecessor, Park Geun-hye, according to Olympic committee statements. But she had adopted a hard line toward the North, and soon had other things to worry about. Beginning in late 2016, South Korea was all but paralysed for months as Park was impeached and removed from office. So Bach reached out to the Chinese president, Xi Jinping, hosting him in January 2017 in Lausanne, Switzerland.
Xi seemed receptive to Bach's questions and willing to help, but also made clear that China's influence over North Korea was limited.
Then, on the Fourth of July, as Bach was finishing a trip to Beijing and Seoul, everything changed. North Korea tested its first intercontinental ballistic missile, which appeared capable of reaching Alaska. The missile test was a blow to Moon, whose election had restored to power the nation's progressive left, which favours closer ties with North Korea.
Moon saw the Olympics as his best chance to ease tensions with the North. Even after the missile test in July, Moon extended an olive branch, using a speech in Berlin to invite the North
to the games and remind Kim that the IOC was on hand to make the arrangements. But Kim launched another ICBM that month, one capable of hitting California. About a week later, Trump warned that he would unleash "fire and fury" against the North if it endangered the US.
Amid the rising hostilities, the Olympics receded from the agenda. Pressing forward, Bach turned again to China, meeting Xi in Tianjin in August, Olympic officials announced. But China was so angry at North Korea for its missile tests that it had little interest in lobbying Kim about the Olympics, Chinese officials said.
Bach travelled to Seoul again in late September to huddle with Moon. The meeting took place a day after Trump addressed the UN General Assembly and threatened to "totally destroy" North Korea if it threatened the US.
In his own UN speech, Moon made the case again for Pyeongchang. "My heart is filled with great joy when I imagine North Korean athletes marching into the stadium during the opening ceremony," he said. But his plea was overshadowed by Kim, who issued an unusual personal statement that denounced Trump as a "mentally deranged US dotard."
In late November, North Korea tested another ICBM, a new model that put the entire continental US within target range. With time running out, Moon sought help from the Trump administration. Just as North Korea preferred to deal with the US alone in nuclear negotiations, some argued that the North wanted Washington to step up on the Olympics, too.
In Washington, the Trump administration began discussing Moon's position. The most sensitive question was his proposal to delay the joint military exercises that were scheduled to begin near the end of the Olympics and during the Paralympic Games.
Some officials argued that any delay would be seen as a concession to Kim and undermine the Trump administration's "maximum pressure" approach to the North. But as the administration deliberated, word of South Korea's preference for a delay began to appear in news reports. Then, during the youth soccer tournament in Kunming, Moon publicly confirmed that he had suggested postponing the exercises.
In the flurry of diplomacy that followed, the US publicly agreed to the delay and Kim announced that he would send his athletes, surprising the world. And in a surprise development, the North said Kim's influential sister, Kim Yo Jong, would attend the games, making her the first immediate member of the North's ruling family to set foot in the South.
But the Olympics hardly resolve the nuclear standoff. Before heading to the games, Vice President Mike Pence delivered perhaps his harshest remarks about the North Korean regime. "The American people, the people of Japan and freedom-loving people across the wider world long for the day when peace and prosperity replace Pyongyang's belligerence and brutality," he said.