With wide grins and a historic handshake, U.S. President Donald Trump and North Korea's Kim Jong-un met at the heavily fortified Demilitarized Zone on Sunday and agreed to revive talks on the pariah nation's nuclear program. Trump, pressing his bid for a legacy-defining deal, became the first sitting American leader to step into North Korea.

What was intended to be an impromptu exchange of pleasantries turned into a 50-minute meeting, another historic first in the year-long rapprochement between the two technically warring nations. It marked a return to face-to-face contact between the leaders after talks broke down during a summit in Vietnam in February. Significant doubts remain, though, about the future of the negotiations and the North's willingness to give up its stockpile of nuclear weapons.

The border encounter was a made-for television moment. The men strode toward one another from opposite sides of the Joint Security Area and shook hands over the raised patch of concrete at the Military Demarcation Line as cameras clicked and photographers jostled to capture the scene.

After asking if Kim wanted him to cross, Trump took 10 steps into the North with Kim at his side, then escorted Kim back to the South for talks at Freedom House, where they agreed to revive the stalled negotiations.

The spectacle marked the latest milestone in two years of roller-coaster diplomacy between the two nations. Personal taunts of "Little Rocket Man" (by Trump) and "mentally deranged U.S. dotard" (by Kim) and threats to destroy one other have given way to on-again, off-again talks, professions of love and flowery letters.

"I was proud to step over the line," Trump told Kim as they met in on the South Korean side of the truce village of Panmunjom. "It is a great day for the world."

Watch: Trump crosses into North Korea

Donald Trump became the first sitting American president to step into North Korea, meeting with Kim Jong-un at the heavily fortified Demilitarized Zone on Sunday. 2:19

Kim hailed the moment, saying of Trump, "I believe this is an expression of his willingness to eliminate all the unfortunate past and open a new future." Kim added that he was "surprised" when Trump issued an unorthodox meeting invitation by tweet on Saturday.

As he left South Korea on his flight to Washington, Trump tweeted that he had "a wonderful meeting" with Kim. "Stood on the soil of North Korea, an important statement for all, and a great honour!"

Trump had predicted the two would greet one another for about "two minutes," but they ended up spending more than an hour together. The president was joined in the Freedom House conversation with Kim by his daughter and son-in-law, Ivanka Trump and Jared Kushner, both senior White House advisers.

Stalled talks

Substantive talks between the countries had largely broken down after the last Trump-Kim summit in Hanoi, which ended early when the leaders hit an impasse.

The North has balked at Trump's insistence that it give up its weapons before it sees relief from crushing international sanctions. The U.S. has said the North must submit to "complete, verifiable and irreversible denuclearization" before sanctions are lifted.

As he announced the resumption of talks, Trump told reporters "we're not looking for speed. We're looking to get it right."

Watch: Trump hails 'historic moment' with Kim

"It was an honour that you asked me to step over that line and I was proud to step over the line," U.S. president says. 0:26

He added that economic sanctions on the North would remain. But he seemed to move off the administration's previous rejection of scaling back sanctions in return for piecemeal North Korean concessions, saying, "At some point during the negotiation, things can happen."

Peering into North Korea from atop Observation Post Ouellette, Trump told reporters before he greeted Kim that there had been "tremendous" improvement since his first meeting with the North's leader in Singapore last year.

Trump claimed the situation used to be marked by "tremendous danger" but "after our first summit, all of the danger went away."

But the North has yet to provide an accounting of its nuclear stockpile, let alone begin the process of dismantling its arsenal.

Kim invited to U.S.

The latest meeting, with the U.S. president coming to Kim, represented a striking acknowledgement by Trump of the authoritarian Kim's legitimacy over a nation with an abysmal human rights record. Kim is suspected of having ordered the killing of his half brother through a plot using a nerve agent at a Malaysian airport in 2017. Meantime, the United Nations said in May that about 10 million people in North Korea are suffering from "severe food shortages" after the North had one of the worst harvests in a decade.

Trump told reporters he invited the North Korean leader to the United States, and potentially even to the White House.

"I would invite him right now," Trump said, standing next to Kim. Speaking through a translator, Kim responded that it would be an "honour" to invite Trump to the North Korean capital of Pyongyang "at the right time."

U.S. President Donald Trump, with South Korean President Moon Jae-in, right of Trump, views North Korea from the Korean Demilitarized Zone from Observation Post Ouellette at Camp Bonifas in South Korea on Sunday. (Susan Walsh/Associated Press)

Trump became the first sitting U.S. president to meet with the leader of the isolated nation last year when they signed an agreement in Singapore to bring the North toward denuclearization.

In the midst of the DMZ gathering, Trump repeatedly complained that he was not receiving more praise for de-escalating tensions on the Korean Peninsula through his personal diplomacy with Kim. Critics say Trump had actually inflamed tensions with his threats to rain "fire and fury" on North Korea, before embracing a diplomatic approach.

Democrats skeptical

Meanwhile, Democratic lawmakers — including some running for the White House — said there's little in Trump's diplomatic track to convince them that his meeting with Kim may lead to a nuclear breakthrough.

Trump is coming under criticism for what Democrats see as his affinity for authoritarian leaders such as Kim and they are skeptical that the Trump-Kim sit-down at the Demilitarized Zone may amount to anything more than a photo opportunity.

Sen. Chuck Schumer said "dictators seem to get elevated and people who believe in democracy not."

Former Obama Housing Secretary Julian Castro, a presidential candidate, wonders why Trump appears keen to raise Kim's profile when Kim hasn't abided by past commitments about the North's weapons programs.

And Sen. Bernie Sanders, also a 2020 candidate, says he's not opposed to sitting down with America's adversaries, but he says "we need real diplomacy" and he hasn't seen that under Trump.