Boris Johnson ruled out supporting the US in any military action in Iran.

"If you were to ask me whether I think should we now, if I were to be prime minister now, would I be supporting military action against Iran, then the answer is no," he said on Monday.

Jeremy Hunt, the UK foreign secretary, also warned that the US and Iran risked triggering an "accidental war."

Visit Business Insider's homepage for more stories.

Boris Johnson indicated to US President Donald Trump that he would not support US-led military strikes against Iran, as tensions between Washington and London deepened following the row over the departure of Britain's ambassador to the US.

Speaking at a leadership debate on Monday evening, Johnson said that Western administrations should instead focus on diplomatic solutions to prevent Iran from building a nuclear weapon.

Asked whether he would back the US on military intervention, Johnson said, "I'm going to be very candid with you all tonight: If you say that going to war with Iran now represents a sensible option for us in the West, I just don't believe it is."

He added: "Diplomacy must be the best way forward. If you were to ask me whether I think should we now, if I were to be prime minister now, would I be supporting military action against Iran, then the answer is no."

Foreign Secretary Jeremy Hunt, the other candidate to replace Theresa May as prime minister, said he was "on exactly the same page" as Johnson on the issue of Iran and warned that there was a risk of "accidental war" in the region.

Hunt added that there was a "small window" of hope for preventing the Iran nuclear deal from unraveling entirely, following Trump's decision last year to withdraw the US from it.

Sir Kim Darroch, the UK ambassador in Washington, said in a batch of leaked memos that Trump had spiked the Iran nuclear deal in an act of "diplomatic vandalism" to spite his predecessor, Barack Obama.

Read more: Trump axed Iran nuclear deal to spite Obama, Darroch said

Johnson, the former foreign secretary, was last week accused of trying to cozy up to Trump when he refused to back Darroch, whose biting criticisms of the US president were leaked to The Mail on Sunday.

In a series of tweets, Trump called Darroch "pompous" and "a very stupid guy." Johnson refused to condemn the comments, and Darroch resigned.

Darroch told friends that Johnson's refusal to back him was a factor in his resignation, leading some of Johnson's colleagues to accuse him of throwing the ambassador "under a bus."

Johnson's comments on Monday came against a backdrop of heightened tensions in the Gulf. Britain said last week that a navy warship drove off three Iranian patrol boats that were approaching a British tanker as it sailed through the Strait of Hormuz, the latest in a series of military incidents that some think could lead to war.

The US and Iranian governments have repeatedly insisted that they do not intend to start a war, but Trump has said military action remains an option, despite canceling a planned airstrike after Iran shot down an American drone last month.

Hunt and Johnson also condemned tweets in which Trump suggested that four congresswomen of color, including Rep. Alexandria Ocasio-Cortez, should return to the "broken and crime infested places from which they came."

Johnson called the tweets unacceptable.

"When you are the leader of a great multiracial, multicultural society, you simply can't use that sort of language about sending people back," he said. "I mean, that went out decades and decades ago — and thank heavens for that."

Hunt agreed, describing the comments as "totally offensive."

The winner of the Conservative leadership contest is set to be announced next week and installed in Downing Street as prime minister by the end of the month.