Former US President Barack Obama was under pressure from certain Middle Eastern leaders to bomb Iran, former US secretary of State John Kerry has revealed.

Speaking at an annual retreat of "mediators and peace process actors" in Oslo, Norway, Kerry said the landmark nuclear deal between Iran and six world powers helped Washington prevent war.

"We were hurtling toward conflict," the former top US diplomat said Tuesday. "I mean, there's just no other way to describe it."

"Leaders in the region were saying to me personally, and to the president, President Obama, you should bomb these guys," Kerry added. "That's the only way to resolve this issue."

"And we chose a different path," he said. "What we did is to find a mutually acceptable way to guarantee that both sides were able to agree on a path forward that met both sides' needs."

Saudi Arabia and Israel had fiercely criticized the Obama administration for trying to resolve the Iranian nuclear issue at the negotiating table instead of opting for a military solution.

Kerry then noted that both sides had to abide by the deal and fulfill their obligations under the 2015 deal, known as the Joint Comprehensive Plan of Action (JCPOA).

The comments were an indirect jab at Obama’s successor, President Donald Trump, who has consistently criticized the historic deal, calling it “one of the worst deals ever made.”

The new Republican president has also threatened to scrap the JCPOA, accusing Iran of “not living up to the spirit” of it.

Shortly before Trump’s January 20 inauguration, Kerry said the nuclear accord was one of Obama's policy victories and warned Trump that canceling it would harm the US in an irreparable way.

Tehran has warned that it would restore its nuclear activities to the pre-JCPOA level, if the US fails to keep its end of the bargain.

The International Atomic Energy Agency has on multiple occasions verified Iran’s adherence to its commitments under the JCPOA.

(L-R) Iran Foreign Minister Mohammad Javad Zari, high representative of the European Union Federica Mogherini, Norway´s Foreign Minister Boerge Brende, Indonesian Foreign Minister Retno Marsudi and former US Secretary of State John Kerry attend a press conference at the Oslo Forum at Losby Gods, outside Oslo, June 13, 2017. (Photo by AFP)

During the Oslo forum, Iranian Foreign Minister Mohammad Javad Zarif discussed the deal with the European foreign policy chief Federica Mogherini.

Zarif said Washington had failed to honor its end of the deal, asserting that Tehran was not surprised by the failure.

Mogherini, on the other hand, said she was confident that the US will keep “something that is working,” asserting that “in any case the European Union will guarantee that the deal keeps.”

Trump has made a major reversal on Obama’s Middle East policies. His first foreign trip was dedicated to encouraging regional Arab nations to stand in “unity” with Israel against Iran, according to American officials.