On Saturday, Mr. Trump said he had a “very good talk” with Mr. Moon. “Things are going well,” he tweeted. “Time and location of meeting with North Korea is being set.” Later, at a rally in Michigan, Mr. Trump told supporters that he deserved virtually all the credit for the success of the meeting between the North and the South.

The price of failure would be high for Mr. Trump. The United States could face a split with its ally South Korea, which is deeply invested in ending its estrangement from the North. Tensions could flare with China, North Korea’s main trading partner, which only grudgingly signed on to the sanctions and would be likely to balk at keeping them in place if Mr. Kim is talking about peace.

Mr. Trump is also moving on other fronts that could undercut his negotiations with Mr. Kim. He appears more likely than ever to rip up the Iran nuclear deal as he faces his next deadline of May 12 to decide whether to reimpose sanctions on Tehran.

Walking away from one nuclear disarmament deal while trying to strike another would be a trick, even for a self-proclaimed dealmaker like Mr. Trump.

There is little question, senior officials and analysts said, that the American-led sanctions, combined with Mr. Trump’s bellicose vows to rain “fire and fury” on North Korea if it threatened the American homeland, helped bring Mr. Kim to the table.

But Mr. Trump is only one of three actors in this drama, and perhaps not the most crucial one. Mr. Moon, a progressive former human rights lawyer, ran for office on a platform of conciliation with the North and has moved aggressively to deliver on that promise. He, not Mr. Trump, has set the pace and terms of the negotiation with the North, though American officials say that Seoul is closely coordinating with Washington.

Mr. Kim, for his part, made a bold bet on diplomacy. His motives for seeking a rapprochement are open to debate. Skeptical analysts said the advancements in North Korea’s intercontinental ballistic missile program — as much as sanctions or threatened military strikes — made the timing right for an overture. Others say he is replaying the cycle of provocation and conciliation pioneered by his father and grandfather.