TOKYO -- Although U.S. President Donald Trump's now famous Twitter invitation to North Korean leader Kim Jong Un on Saturday looked almost spontaneous, it seems he had always envisioned a Panmunjom handshake as the climax of his Asia trip.
At the Osaka Group of 20 summit, as the world held its breath for the big meeting between Trump and Chinese President Xi Jinping, neither Xi nor South Korean President Moon Jae-in nor Japanese Prime Minister Shinzo Abe were able to ascertain the U.S. president's true ambitions.
As a result all the G-20 summitry became but an opening act for the main event at the Demilitarized Zone dividing North and South Korea.
Hours before the tweet, on Friday night, Xi and Trump were together for the G-20 gala dinner at the Osaka Geihinkan guesthouse in the compound of Osaka Castle.
Xi arrived at the venue in his special bulletproof Hongqi (red flag) car, which was brought into Japan for the first time. Trump arrived in Cadillac One, the presidential state car otherwise known as "The Beast."
From when they arrived at the castle until the dinner, there was a small window of time. Here the two leaders are thought to have had a talk.
"I was with him last night," Trump said the next day during a breakfast with Saudi Crown Prince Mohammed bin Salman. "A lot was accomplished, actually, last night. The relationship is very good with China," he said, hinting of the secret meeting.
While the two leaders were at the castle, their two trade negotiators were meeting back at Trump's hotel, the prestigious Imperial Hotel Osaka. Under maximum-security, Chinese Vice Premier Liu He slipped into the hotel to meet U.S. Trade Representative Robert Lighthizer.
"Their talks lasted nearly two hours," a source disclosed.
The U.S.-China summit that drew global attention started shortly before noon on Saturday and lasted 80 minutes. But the screenplay had already been drawn up the previous night.
The scenario called for the U.S. and China to restart trade talks -- suspended since the beginning of May -- and also for the U.S. to hold off additional punitive tariffs on Chinese products.
While China's offer to expand its purchases of American goods and protect intellectual property rights were not satisfactory, they were enough to justify going back to the negotiating table.
With the outcome of the following day's summit clear by Friday night, Trump lost more than half of his interest in the meeting with Xi.
And so it was that in the early hours of Saturday Trump sent out a bombshell tweet.
"If Chairman Kim of North Korea sees this, I would meet him at the Border/DMZ just to shake his hand and say Hello(?)!"
Minute by minute, the American president was forming in his head the image of becoming the first sitting U.S. president to step foot in North Korea.
His excitement was visible at the breakfast with the Saudi prince. "I just put out a feeler, because I don't know where he is right now; he may not be in North Korea. But I said, if Chairman Kim would want to meet, I'll be at the border."
The tweet came up later that day when Trump met South Korea's Moon.
Trump asked Moon, "Did you see my tweet?" Moon replied affirmatively. Trump was in a good mood and called on Moon to join him in his efforts, giving him a thumbs-up.
Trump was all atwitter about a third summit with Kim, this time at the truce village of Panmunjom, inside the Demilitarized Zone, or DMZ. He took his excitement into his summit with Xi in a not-so-wide room inside the international conference hall.
By then, Trump was disposed toward his third summit with Kim. The Chinese delegation, which was quick on the uptake, saw through Trump's feelings. But this does not mean China directly mediated between Trump and Kim.
In fact, China feared that if Trump and Moon together met with Kim at the DMZ, the three parties would begin talks toward officially ending the 1950-1953 Korean War, excluding China.
As a proud party to the Korean War armistice, China believes it should be a central player in bringing the war to an official end. Many of its "volunteer soldiers" fought and died alongside North Koreans during the conflict. That Moon might instead take the initiative in declaring peace galls China, still bothered by South Korea's refusal to sign the 1953 armistice.
Beijing's umbrage is not new. About a year and a half ago, China was unhappy that preparations toward the very first U.S.-North Korean summit were progressing with South Korea, not China, as the key mediator.
This time, Moon also guided Trump, albeit as a matter of form, when the U.S. president took the historic step of entering North Korea. Images of Trump, Kim and Moon walking together went viral around the world.
Sometime during the weekend, China realized global attention had shifted from the ongoing summit in Osaka to Panmunjom and tried to demonstrate its role.
During his Saturday meeting with Trump, Xi expressed hope that the U.S. and North Korea would both "show flexibility and resume dialogue as soon as possible." The remark was carried by Chinese state-run media immediately after the U.S.-China summit.
It was an unusually quick turnaround, given that Chinese media must receive permission from above before airing a report.
A short while earlier, Choe Son Hui, North Korea's first vice minister for foreign affairs, had issued a statement describing Trump's proposal to meet Kim at Panmunjom as "very interesting."
"We see it as a very interesting suggestion, but we have not received an official proposal in this regard," Choe said. Such a meeting "would serve as another meaningful occasion in further deepening the personal relations between the two leaders and advancing the bilateral relations."
But as the events unfolded, it became clear that Trump's visit to the DMZ was clearly overshadowing Xi's own recent visit to North Korea.
China's state-run media outlets reflected the unease.
On Sunday, China Central Television's main evening news program skipped reporting about the Trump-Kim encounter at Panmunjom altogether. Instead, CCTV gave extensive coverage to how strong Xi's presence was at the G-20 summit.
Two Trump aides could hold the key to understanding the sequence of events -- from the secret meeting with Xi on Friday night to the 80-minute summit on Saturday and then to the dramatic crossing over to North Korean soil.
They are Ivanka Trump and Jared Kushner. Trump's daughter and her husband, a senior White House adviser, "were the key figures who made the U.S.-China summit happen," one source said. "Particularly Kushner."
When Xi and Trump held their first meeting at the latter's posh Mar-a-Lago estate in the U.S. state of Florida in April 2017, Kushner, Ivanka and their children greeted Xi and his wife Peng Liyuan.
The backstage director of that 2017 Xi-Trump summit was Cui Tiankai, China's ambassador to the U.S., who lobbied Kushner and Ivanka to make the meeting happen. This personal connection played a role in the latest U.S.-China summit.
On June 18, Xi held his first telephone conference with Trump after a long interval and agreed to meet in Osaka. Cui and Kushner laid the groundwork for the agreement.
On this trip, Trump managed to restart two tracks of negotiations -- U.S.-China trade talks and U.S.-North Korea denuclearization talks.
In both cases, Trump merely kicked the can down the road. He has achieved nothing which might go toward settling the U.S.'s trade differences with China or that could clear up the big disagreement with North Korea as to what "denuclearization" means.
But Trump is happy for now.
For better or worse, he dominated the G-20 summit.
Katsuji Nakazawa is a Tokyo-based senior staff writer and editorial writer at Nikkei. He has spent seven years in China as a correspondent and later as China bureau chief. He is the 2014 recipient of the Vaughn-Ueda International Journalist prize for international reporting.