Updated at 11:34 a.m. ET

President Trump delivered a stern warning to North Korea and its outlaw nuclear program as he addressed the United Nations General Assembly Tuesday.

"The United States has great strength and patience," Trump said. "But if it is forced to defend itself or its allies, we will have no choice but to totally destroy North Korea."

Trump took aim at North Korea's leader, Kim Jong Un, with the same nickname he'd used on Twitter.

"Rocket Man is on a suicide mission for himself and for his regime," Trump said.

Even as he threatened a military response to Pyongyang, Trump said he hoped it would not be necessary.

"That's what the United Nations is for. Let's see how they do," he said.

Trump applauded the U.N. Security Council for its recent votes to impose tough economic sanctions on North Korea but stressed the international community must do more to isolate the Kim regime.

Trump also criticized Iran for destabilizing actions in the Middle East and suggested he may withdraw from the nuclear deal struck by the Obama administration with Iran and five other U.N. members.

"Frankly, that deal is an embarrassment to the United States, and I don't think you've heard the last of it, believe me," the president said.

Trump has frequently criticized the nuclear deal, although just last week he passed up an opportunity to break with the agreement and reimpose nuclear sanctions against Iran.

Tuesday's speech was the president's first opportunity to address the world body, which he has faulted in the past for too much talk and too little action.

Trump used the occasion to defend his doctrine of "America First," while arguing that it need not be an impediment to international cooperation.

"As president of the United States, I will always put America first, just like you as the leaders of your countries will always and should always put your countries first," Trump told the international assembly, including dozens of heads of state. "But making a better life for our people also requires us to work together in close harmony and unity to create a more safe and peaceful future for all people."

As president, Trump has frequently tested international cooperation, threatening to withdraw from the Paris Climate Agreement, for example, as well as a trade deal with 11 other countries on the Pacific Rim.

"The United States will forever be a great friend to the world, and especially to its allies," Trump said. "But we can no longer be taken advantage of or enter into a one-sided deal where the United States gets nothing in return."

Copyright 2017 NPR. To see more, visit http://www.npr.org/.