Just as Donald Trump reached one hand out to North Korea, he yanked the other back from Iran.

The president's dramatic withdrawal from the Iran nuclear deal was the most vivid illustration to date of how his impulses and capricious instincts tend to pull him in paradoxical directions. Presidents before have pursued conflicting approaches to tough issues, but rarely so overtly, and rarely in the course of a single speech.

He called Iran's government a "regime of great terror" as he revealed that the U.S. would abandon the deal that it pushed for only three years ago. Then he announced that he'd sent Secretary of State Mike Pompeo to Pyongyang to lay the groundwork for Trump's historic summit with the dictatorial Kim Jong Un, recently described by Trump as "very honorable."

"Plans are being made, relationships are building, hopefully a deal will happen," Trump said of his delicate rapprochement with North Korea. Speaking in the Diplomatic Room of the White House, he waxed optimistic that the U.S. could team up with allies and world powers so that "a future of great prosperity and security can be achieved for everyone."

That was precisely the game plan when the United States in 2015 brokered the landmark accord with Tehran. With painstaking persistence, Trump's predecessor brought U.S. partners Britain, Germany and France together with rivals Russia and China to strike a deal in which Iran agreed to vigorous inspections and strict nuclear limitations.

So what's so different between the deal Trump walked away from Tuesday and the one he's actively seeking with the North? The answer, by all appearances, can be summed up in two words: Barack Obama.

"Whatever Obama did, he wants to undo," said Douglas Brinkley, a presidential historian at Rice University. He pointed out that Obama, in his final weeks, warned Trump that North Korea was America's top national security threat. "He's going to solve it, because Obama couldn't. Obama is proud of the Iran deal, so now Trump's going to derail it."

It's an instinct that has been on display throughout Trump's presidency: where Obama zigged, Trump will zag.

On the world stage, Trump moved quickly as president to pull the U.S. out of the Paris climate agreement that Obama's administration helped broker, abandoned Obama's sweeping free-trade deal with Asia, and pulled back from the historic rapprochement with Cuba. His need to be seen as the anti-Obama has continued closer to home as Trump has rolled back scores of environmental and other Obama-era regulations and took aim, again and again, at Obama's signature health care law.

Most of those decisions had the effect of pulling the U.S. back from overseas obligations and alliances — real-life examples of his "America First" doctrine. Yet reneging so frequently on commitments the U.S. made in the past also carries risk as Trump seeks to persuade North Korea that the U.S. lives up to its word.

So there was an element of irony as Trump cast his dual decisions — pulling out of the Iran deal and sending Pompeo to North Korea — as sending a single, unified message.

"The United States no longer makes empty threats," Trump said, referring to Iran. With respect to the North, he added: "When I make promises, I keep them."

He argued that the nuclear deal was wholly inadequate to keep the U.S. safe from Iran, but held out the possibility he could negotiate a tougher deal with Tehran in the future. Iran has already ruled that out.

For better or for worse, Trump now owns the future of Iran's nuclear development, to the extent he's unable to strike a better deal. Iran's leaders may follow through on threats to immediately ramp up uranium enrichment far beyond the limits imposed by the deal, which even the U.S. says Iran was abiding. It will be difficult in the short term for Trump to argue that the United States is better off under that scenario than under the previous deal.

And in laying out his complaints about the Iran deal in such detail, Trump set an incredibly onerous litmus test that any forthcoming pact with North Korea must now ostensibly pass.

He faulted the Obama-era pact for allowing Iran to keep enriching uranium, rather than a full halt. He lamented that nuclear inspectors didn't have the right to access Iran's military facilities, and that the deal lacked punishments for Iran's other troubling behavior "all around the world."

By Trump's own standard, then, his North Korea talks must yield a deal in which North Korea halts all enrichment and lets U.N. inspectors into its military bases. It must go beyond nuclear issues to address other North Korean transgressions alleged by the U.S., such as cyber attacks and the assassination of Kim's half brother in a Malaysian airport.

North Korea, unlike Iran, already has a nuclear bomb — and enough fissile material for dozens of them, most estimates show. That would have to be removed from North Korea's control to make the deal stronger than the one Obama reached with Tehran.

All that will be easier said than done. North Korea's atomic program is decades old and is suspected to include secret sites, possibly buried underground. Nuclear inspections experts say it will be far harder to verifiably disarm than Iran ever was.

___

EDITOR'S NOTE — Josh Lederman has covered foreign policy, politics and the White House for The Associated Press since 2012.