PANMUNJOM/SEOUL, South Korea (Reuters) - U.S. President Donald Trump became the first sitting U.S. president to set foot in North Korea on Sunday when he met its leader, Kim Jong Un, in the Demilitarized Zone (DMZ) between the two Koreas and agreed to resume stalled nuclear talks.

The meeting, initiated by a spur-of-the-moment tweet by Trump that Kim said took him by surprise, once again displayed the rapport between the two. But they are no closer to narrowing the gap between their positions since they walked away from their summit in February in Vietnam.

The two men shook hands warmly and expressed hopes for peace when they met for the third time in just over a year on the old Cold War frontier that for decades has symbolized the hostility between their countries, which are technically still at war.

Trump, escorted by Kim, briefly crossed a military demarcation line into the North side of the Joint Security Area (JSA), patrolled by soldiers from both Koreas.

Moments later, they returned to the southern side and joined South Korea’s President Moon Jae-in for a brief chat, marking an unprecedented three-way gathering.

Trump and Kim then held a closed-door meeting for nearly an hour.

“We just had a very, very good meeting,” Trump said after the talks. “We’ll see what can happen.”

He said both sides would set up teams to push forward stalled talks aimed at getting North Korea to give up its nuclear weapons, adding “speed is not the thing.”

Pope Francis, making his weekly address in St. Peter’s Square, praised the meeting. “I salute the protagonists, with a prayer that such a significant gesture will be a further step on the road to peace, not only on that peninsula, but for the good of the entire world,” he said.

Trump and Kim met for the first time in Singapore in June last year, and agreed to improve relations and work toward the denuclearization of the Korean peninsula.

But the second summit in Hanoi broke down after the two sides failed to narrow differences between a U.S. demand for North Korea to give up its nuclear weapons and a North Korean demand for sanctions relief.

‘PLENTY OF TIME’

Kim looked relaxed and smiled as he chatted with Trump amidst a throng of press photographers, aides and bodyguards.

Slideshow ( 19 images )

Trump said the two leaders “moved mountains” to arrange the last-minute meeting.

“I was surprised to see you expressed an intent to meet,” Kim told Trump, referring to Trump’s offer for a meeting in a tweet on Saturday. Trump came to South Korea after attending a Group of 20 summit in Osaka, Japan.

“This is an expression of his willingness to leave behind the past and work toward a new future,” Kim said.

Slideshow ( 19 images )

Kim said it would be a great honor if Trump visited his capital of Pyongyang. The two agreed to visit each other’s country “at the right time,” Trump said.

“To cross that line was a great honor,” Trump said, referring to his brief incursion into the North Korean side of the DMZ. “It’s a great day for the world.”

But there has been little sign that North Korea and the United States are any closer to narrowing differences on the nuclear issue.

U.S. Secretary of State Mike Pompeo told reporters shortly before departing South Korea that a fresh round of talks will likely happen “sometime in July” and the North’s negotiators would be foreign ministry diplomats.

Pompeo made clear in a tweet later that the United States believed that sanctions put in place under U.N. Security Council resolutions needed to remain in place as talks moved forward.

“We remain ready to engage (North Korea) in negotiations, but remain firm on the implementation of UNSCRs ahead of denuclearization,” he said.

Shin Beom-chul, a senior fellow at the Asan Institute for Policy Studies in Seoul, said the meeting between the two leaders was important in reviving working-level talks.

“But the North wouldn’t easily change its stance, even though Trump has effectively responded to the so-called top-down approach cherished by Kim,” he said.

Trump said he had “plenty of time” and was in “no rush” to reach a deal.

“We want to get it right,” he said.

North Korea has pursued nuclear and missile programs for years in defiance of U.N. Security Council resolutions, and easing tensions with North Korea is one of the U.S. president’s top foreign policy priorities.

The DMZ was set up after the 1950-53 Korean War ended in an armistice, not a truce, leaving North Korea and the United States still technically at war.