President Donald Trump meets with North Korean leader Kim Jong Un at the border village of Panmunjom in the Demilitarized Zone, South Korea, on June 30. (AP Photo)

The dramatic meeting between U.S. President Donald Trump and North Korean leader Kim Jong Un at the Demilitarized Zone on June 30 may not have been such a surprise after all.

According to diplomatic sources with good contacts in Washington and Seoul, a message that Trump arranged to be delivered to Kim in late June by a high-ranking official who met with North Korean counterparts indicated that he wanted to meet the North Korean leader at the Panmunjom border village. Trump had planned to visit the DMZ during his visit to South Korea after attending the Group of 20 summit meeting in Osaka.

Trump told the official to discuss the matter with North Korea and received confirmation that Pyongyang would send a predetermined signal if Kim was willing to meet at the DMZ, the sources said.

On June 29, Trump tweeted that he would like to meet with Kim. A few hours later, Choe Son Hui, North Korea's first vice foreign minister and a close associate of Kim, responded in an unusually quick manner and said a meeting between the two leaders would be "meaningful."

That, according to sources, was apparently the "signal" U.S. officials wanted. Stephen Biegun, the U.S. special envoy for North Korean affairs, who was in Seoul, visited the Panmunjon village for discussions with North Korean officials about how the meeting set for the following day would proceed as well as security matters.

When Trump met Kim, he mentioned the tweet and thanked the North Korean leader for responding right away. Kim Jong Un also said he was surprised when Trump proposed the meeting the previous day in an apparent ploy to fall in line with Trump's desire to cast the meeting as a spur-of-the-moment event that largely came about because of the personal relationship of trust between the leaders.

A convergence of goals between the two leaders apparently helped bring about the meeting. Trump wanted to highlight the direct line of communications he had with Kim ahead of his presidential re-election bid next year, while the North Korean leader wanted to maintain the framework of top-level discussions in order to convince the United States to relax the economic sanctions it has in place against North Korea.

(This article was written by Takeshi Kamiya in Seoul and Koji Sonoda in Washington.)