US President Donald Trump has told the UN General Assembly that America would destroy North Korea if forced to defend itself or its allies.
In his debut speech, he mocked North Korea's leader, Kim Jong-un, saying: "Rocket man is on a suicide mission."
North Korea has tested nuclear bombs and missiles in defiance of the UN.
Just before Trump spoke, UN Secretary General Antonio Guterres had urged statesmanship, saying: "We must not sleepwalk our way into war."
The American leader also attacked Iran, saying it was a "corrupt dictatorship" which was intent on destabilising the Middle East.
He called on the government in Tehran to cease supporting terrorism and again criticised the Obama-era international agreement over Iran's nuclear programme, which he called an embarrassment.
Washington has repeatedly warned North Korea over its weapons tests, which violate UN Security Council resolutions.
The crisis worsened last month when the North announced plans to test missiles around the US Pacific territory of Guam.
"If [the US] is forced to defend itself or its allies, we will have no choice but to totally destroy North Korea," Trump said.
President Trump's threat to "totally destroy" North Korea is implausible, according to Stewart Patrick, a senior fellow at the New York think tank the Council on Foreign Relations.
"I actually am very sceptical," he told the BBC.
"I think the folks in the Pentagon when they look at military options are just aghast at the potential loss of life that could occur with at a minimum hundreds of thousands of South Koreans killed in Seoul.
"And I'm sure that [for] the South Korean government, the last thing on their mind right now is the notion that the United States should launch an attack, a pre-emptive attack of some sort on North Korea."
President Trump's speech was at one and the same time an eloquent exposition of his doctrine of "America First" and some fulsome (and perhaps unexpected) praise for the United Nations as a body that can bring together these sovereign states to tackle the world's problems.
In contrast to the focus on globalisation that has driven so much of foreign policy discussion since the 1990s, Trump saw national sovereignty as the main pillar of the international system. There was a nod to the old axis of evil theme.
He opposed "the righteous many" to "the wicked few", his rogues' gallery taking in a predictable cast of North Korea, Iran and Venezuela.
Nonetheless Trump's world view contained many contradictions.Where exactly is the boundary between national sovereignty and collective action? And does America's newfound foreign policy pragmatism extend just to calling for the return of democracy in Iran and Venezuela or actually for doing something practical about it?
The 2015 deal between Iran, the US and other world powers, including China and Russia, was designed to prevent Iran developing a nuclear weapon.
"Frankly, that deal is an embarrassment to the United States, and I don't think you've heard the last of it," Trump told the General Assembly on Tuesday.
Iran's government, he said, was bent on "death and destruction", while its people wanted change.
"Other than the vast military power of the United States... Iran's people are what their leaders fear the most," he said.
Using almost biblical language, the American leader portrayed the world in terms of "decent nations" confronted with "rogue regimes".
"The scourge of our planet today is a small group of rogue regimes that violate every principle on which the United Nations is based," he said.
"They respect neither their own citizens nor the sovereign rights of their countries. If the righteous many do not confront the wicked few then evil will triumph.
"When decent people and nations become bystanders to history the forces of destruction only gather power and strength."
The General Assembly was opened by Guterres, who said that millions of people were living in dread as a result of North Korea's nuclear and missile tests.
"The use of nuclear weapons should be unthinkable," he said. "But today global anxieties about nuclear weapons are at the highest level since the end of the Cold War."
The former head of the UN refugee agency also spoke of being "pained to see the way refugees and migrants have been stereotyped and scapegoated - and to see political figures stoke resentment in search of electoral gain".
The latter is a charge that has often been levelled against Trump, who condemned "uncontrolled migration" in his speech on Tuesday. He insisted that America was a "compassionate nation" which had spent billions of dollars on helping refugees return to their home countries.
According to Reuters news agency, when Trump made his remarks about destroying North Korea, one man in the audience covered his face with his hands, while Swedish Foreign Minister Margot Wallstrom crossed her arms.
Loud, startled murmurs filled the hall, according to the agency.
The General Assembly, which continues until Monday, is an annual event, bringing together leaders of the UN's 193 member states.