LONDON — British Foreign Secretary Boris Johnson said Monday that nobody wants armed conflict over North Korea’s nuclear ambitions, but that U.S. President Donald Trump is right to keep the option of military action open.

In a speech on global security in London, Johnson urged the government of Kim Jong Un to “change course” and engage in diplomacy to resolve the crisis.

“By continuing to develop nuclear capabilities, Kim risks provoking a reaction in the region that is at once defensive and competitive, that reduces not increases his security and therefore reduces not increases the survival chances of the regime,” Johnson said.

North Korea has dramatically ramped up its nuclear weapons program, launching intercontinental ballistic missiles that can potentially strike the U.S. mainland and a conducting its largest-ever underground nuclear explosion.

Johnson called for North Korea’s neighbor China to lead efforts to pile economic pressure on Pyongyang, but also said U.S. Secretary of State Rex Tillerson had rightly offered North Korea “sensible reassurances” that it does not seek regime change or invasion.

But he said Trump has an “absolute duty to prepare any action” to keep America and its allies safe.

“I don’t think anybody can conceivably want a military solution to this problem,” Johnson said. “And yet clearly it must remain on the table.”

Johnson told a conference organized by the Chatham House international affairs think tank that diplomacy had succeeded in limiting the spread of atomic weapons beyond a handful of countries.

He said that if North Korea changed tack, “the world can show that it is once again capable of the diplomatic imagination that produced the Nuclear Non-Proliferation Treaty” and the Iran nuclear deal.

In an implicit rebuke to Trump, he said the 2015 accord curbing Iran’s nuclear program had avoided the “nightmare” of a nuclear arms race in the Middle East.

Trump has been fiercely critical of the deal and earlier this month refused to re-certify it under U.S. law, directing Congress to make it more stringent.

The other parties to the accord — Britain, China, France, Germany, Russia and the European Union — have all urged Trump’s administration to stay in the deal.

Johnson said it was crucial the Iran deal survived. He said that “having spoken to some of the most influential figures on Capitol Hill — none of them fans of the Iranian regime — I have absolutely no doubt that with determination and courage the (deal) can be preserved.”

Urging more work to curb nuclear proliferation, he said the alternative was a world of high-stakes standoffs and brinksmanship, what he called “a nuclear version of the final scene of ‘Reservoir Dogs.'”