Boris Johnson and Jeremy Hunt were speaking at a debate hosted by The Sun and talkRADIO (Pictures: MOD).
The next British Prime Minister would not back the US in a war against Iran at the present time.
Both Conservative leadership contenders ruled out supporting Donald Trump's administration should it decide to take military action in the Gulf.
Asked if he would back the US on military intervention, Mr Johnson said going to war with Iran now does not believe it would be "a sensible option" and focus should be on diplomatic efforts.
"Diplomacy must be the best way forward," Mr Johnson said.
"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."
Boris Johnson and Jeremy Hunt were speaking at a debate hosted by The Sun and talkRADIO on Monday evening.
Foreign Secretary Jeremy Hunt, who was fresh from a Brussels meeting of EU foreign ministers on how to reduce tensions with Iran, said he was "on exactly the same page" as his leadership rival on the issue: "I do not think they are looking to do any kind of war, I really don't.
"The risk we have is something different, which is accidental war."
Earlier, on his way into the Brussels meeting, Mr Hunt insisted that the Iran nuclear deal is not yet dead.
He said there was a "small window" of hope for preventing the international agreement aimed at stopping Tehran gaining nuclear weapons from unravelling.
Following the meeting in Brussels, Mr Hunt insisted there can be no "partial" compliance to the deal.
The comments came as the US urged European allies to take a tougher stance on Iran after Mr Trump pulled America out of the nuclear deal with Tehran.
Mr Hunt's attendance at the EU summit came after he offered to help secure the release of the Iranian supertanker Grace 1, held in Gibraltar after being detained in an operation involving British Royal Marines.
There have been heightened tensions in the Gulf recently.
Last week, a Royal Navy warship intervened to drive off Iranian patrol boats after they approached a British tanker as it sailed through the Strait of Hormuz.
It prompted fears the Iranians were trying to seize a UK ship in retaliation for the detention of the Grace 1.
It was the latest in a series of incidents in the region, prompting fears of a slide into all-out conflict.