The president, and his new hard-line team of national security advisers, may think that walking away from the Iran deal will persuade Mr. Kim of his toughness and his determination to secure terms that go far beyond those reached with Iran. More likely, Mr. Kim will see it as proof that the United States cannot be trusted to stick to its commitments and will be reluctant to reach any agreement.

Persuading a country to give up weapons is never easy. The North Koreans have said they need nuclear weapons to deter American aggression. And Mr. Kim has set the pace for most of the recent diplomacy — including his surprise invitation to Mr. Trump and his visit with President Xi Jinping in China. That said, he reportedly told China and South Korea he will discuss “denuclearization” with the Americans.

Denuclearization has had some successes. After Ukraine, Kazakhstan and Belarus inherited thousands of nuclear weapons when the Soviet Union collapsed, the United States persuaded them to transfer the devices to Russia. South Africa had about a half-dozen warheads but gave them up after the end of apartheid. Libya shed its rudimentary nuclear program under pressure from Britain and the United States after the Iraq war.

And in 1994, most likely before North Korea had any nuclear weapons, a limited agreement with the United States froze the North’s plutonium program for about eight years until it fell apart under President George W. Bush.

A serious negotiation with North Korea would include Mr. Trump pressing Mr. Kim to freeze nuclear and missile testing, halt the production of nuclear weapons fuel and the deployment of nuclear weapons and put an Iran-like verification system in place. But why would Mr. Kim agree to any of that if the Americans walk away from the Iran deal? Why would Mr. Kim, or any future adversary for that matter, assume Mr. Trump is negotiating in good faith?

The Iran deal has achieved what it was intended to do — limit Iran’s nuclear program. There is still hope that something similar can be achieved in North Korea. Indeed, Mr. Trump could contribute in an unprecedented way to international peace and security by engaging with Mr. Kim. That possibility will be squandered, though, if the American president escalates a manufactured nuclear crisis with Iran at the very time he is trying to defuse one with North Korea.