PANMUNJOM, South Korea - President Donald Trump met Kim Jong Un at the demilitarized zone between North and South Korea on Sunday, and briefly crossed into North Korea, marking the first time a sitting U.S. president has ever done so.

The two men then held 53 minutes of private talks, and agreed to set up teams to "work out some details" to see if progress could be made in their negotiations over North Korea's nuclear program, Trump said.

"Speed is not the object, we want to see if we can do a really comprehensive, good deal," Trump said after the talks. "Nobody knows how things turn out, but certainly this was a great day, this was a very legendary, very historic day."

"It'll be even more historic if something comes up, something very important," he added. "Very big stuff, pretty complicated, but not as complicated as people think."

Trump's meeting with Kim came four months after the breakdown of their second summit in Hanoi, although Trump argued that summit had been a success because his relationship with the North Korean leader had only deepened.

History was made at 3:45 p.m. local time Sunday, as Trump and Kim walked up to the demarcation line dividing the two Koreas and shook hands. Kim then invited Trump to cross into North Korea. The two men strolled a few yards to reach a road on the North Korean side, stayed a few seconds then both crossed back into South Korea.

"Good to see you," Kim said. "I never expected to see you in this place."

Kim, dressed in a black Mao suit, said the very fact of them meeting had a lot of significance.

"We want to bring an end to our unpleasant past and bring in a new future, so this is a very courageous and determined act," he said. "This handshake of peace itself serves to demonstrate that today is different from yesterday. "

Trump said it was "my honor" to cross into North Korea.

"A lot of really great things are happening, tremendous things," he said. "We met and we liked each other from Day One, and that was very important."

The two men then met with South Korean leader Moon Jae-in, before adjourning for bilateral talks in the Inter-Korean House of Freedom, on the southern side of the border.

Sitting down before the talks began, Kim again underlined the importance of the meeting. "I hope it can be the foundation for better things that people will not be expecting," he said.

"Our great relationship will provide the magical power with which to overcome hardships and obstacles in the tasks that needs to be done from now on."

Earlier, Trump also spoke warmly of Kim.

"We've developed a very good relationship and we understand each other very well. I do believe he understands me, and I think I maybe understand him, and sometimes that can lead to very good things."

Afterward, Trump said the two sides would designate teams, with the U.S. team headed by special envoy Stephen Biegun under the auspices of Secretary of State Mike Pompeo, to start work in the next two to three weeks. "They'll start a process, and we'll see what happens," he said.

Unconfirmed media reports have suggested that Pompeo and Biegun's counterparts were both disciplined or demoted in the wake of the Hanoi summit: Trump said Kim would now put someone in charge "who we know and we like."

South Korean President Moon Jae-in called the meeting a historic moment in the peace process on the Korean Peninsula.

"Through today's meeting, the peace process for complete denuclearization of the Korean Peninsula and establishment of permanent peace has overcome a big hurdle," he said. "It gave a big hope to the world and the 80 million people of South and North Korea."

Trump had broadcast his offer to meet Kim at the border in a morning tweet in Osaka, Japan, at the Group of 20 summit on Saturday. A senior North Korean official responded soon after that the offer was "interesting."

Whether the meeting was really arranged in just 24 hours remains open to question - the two men also exchanged letters earlier this month - but Trump said the idea had simply occurred to him on Saturday.

"Yesterday I was just thinking 'I am here, let's see whether or not we can say hello to Kim Jong Un,'" he said. "I put the word out and he got back and wanted to do it from the beginning and so did I."

Trump later said the two sides had "moved mountains" to organize the meeting at such short notice.

Andrei Lankov, a professor at Kookmin University in Seoul, said it was inconceivable that the leaders of two powerful nations had arranged a meeting at such short notice, calling it a "show" designed to send a political message, without raising expectations about them making actual progress.

"They needed something that is strong on optics but weak on substance," he said. "Substance is difficult or impossible to achieve in the available time frame, and involves such painful issues that they would like to keep pushing can down the road."

Trump, under fire for inflaming tensions with Iran, wanted to portray himself as a diplomat who prevented war with North Korea. Moon wanted to shore up his domestic support and prevent the Peninsula from sliding back into hostility. And Kim wanted to counter domestic criticism that his engagement with the United States had failed to yield results, Lankov said.

Moon also greeted Kim at the border after the theater of the Trump-Kim meeting but did not join the two men for their private talks. Only last week, North Korea's foreign ministry said it did not want Seoul mediating and told South Korean authorities to "mind their own business at home."

In remarks to the media throughout Sunday, Trump repeatedly congratulated himself for calming tensions on the Korean Peninsula, arguing that the region would have been engulfed in war if he had not been elected president.

"We are in much different place than we were 2 1/2 years ago," he said, adding he found "insulting" that the press could say otherwise.

Throughout the day, Trump repeatedly attacked the media for its coverage and failure to appreciate his achievements in lowering tensions, saying the DMZ used to be "very dangerous" but that is was much less so since his first summit with Kim in Singapore.

"I say that for the press. They have no appreciation for what is being done, none," he insisted.

"There was great conflict here prior to our meeting in Singapore," he added. "After our first summit, all of the danger went away."

Trump earlier pointed to the fact that North Korea has ceased nuclear tests, and that tensions have eased between the two countries, but he also misrepresented what had been achieved, claiming that North Korea had ceased ballistic missile tests and was continuing to send back remains of U.S. servicemen killed in the Korean War.

In fact, North Korea has tested short-range ballistic missiles since the Hanoi summit, while the Pentagon says contacts with Pyongyang over the return of remains have ceased.

Critics say Trump actually inflamed tensions dangerously in the first months of his presidency, but has now gone so far the other way he is rapidly legitimizing North Korea as a nuclear weapons state and letting Kim off the hook for his massive human rights violations in one of the most repressive regimes on the planet.

"At the beginning, there was a lot of anger between myself and Kim Jong Un," Trump said. "Something happened, there was a point at which it happened and all of a sudden you get along."

But Lankov said Trump no longer highlighted North Korean denuclearization as frequently as in the past, showing he was finally realizing this was an unrealistic goal.

"He began to realize his only chance is not solving the problem but managing the problem," he said. "He began to move the goal posts."

While Trump and Kim held their bilateral talks on Sunday, the U.S. president's daughter and son-in-law, Ivanka Trump and Jared Kushner, also briefly crossed onto North Korean soil. Asked how North Korea was, Ivanka responded "Surreal."

This article was written by Seung Min Kim and Simon Denyer, reporters for The Washington Post.