LONDON--British Prime Minister David Cameron had a "cordial" and "substantive" 30-minute phone call with Iranian President Hasan Rouhani on Thursday during which both leaders reaffirmed their commitment to securing a deal in negotiations over Iran's nuclear program, a U.K. government spokeswoman said.

The two also discussed the situation in Yemen and some bilateral issues, including talks about reopening of the British embassy in Tehran.

"The prime minister emphasized to the president that it was important for everyone to show flexibility on the key elements outstanding in the [nuclear] discussions if a deal is to be achieved," she said. "And the PM made a point that Iran needs to recognize that there are concerns held by the wider international community about whether Iran's nuclear program is being developed for peaceful purposes and the Iranians needed to take on board that the E3+3 [a bloc of three EU nations--Germany, France and the U.K.--and three non-EU nations--the U.S., Russia and China] would need to allay those concerns through any deal."

The spokeswoman declined to give details of the substance of the nuclear negotiations, but said Britain was clearly approaching the talks with the view that it was "possible to do a deal with Iran that will ensure we stop Iran from acquiring a nuclear weapon."

Mr. Rouhani also spoke to French President François Hollande on Thursday. A statement from Mr. Hollande's office said the French president "insisted on the need for everyone to work in good faith to achieve a lasting, robust and verifiable agreement" on Iran's nuclear program.

In a series of messages on Mr. Rouhani's official English twitter account, the Iranian president said the country's nuclear program was peaceful and said the lifting of international sanctions on the country was the main step to reaching a deal.

Mr. Rouhani also said countries should abstain from military intervention in Yemen. Earlier, five Persian Gulf states and Egypt lined up to coordinate military action in Yemen after Saudi Arabia launched airstrikes there Thursday at the request of Yemen's president, Abed Rabbo Mansour Hadi.

Britain's government said Thursday that it supported Saudi Arabia's intervention but was not contributing to the effort.

In their phone call, Mr. Cameron made the point to Mr. Rouhani that the best way to ensure that Islamist militant groups like Islamic State do not gain ground in Yemen was to support Mr. Hadi as the legitimate leader of the country, the spokeswoman said. The U.K. prime minister also told Mr. Rouhani that a political process was required to restore stability in Yemen and as part of that, other countries should avoid supporting the Houthi militants, she added.

Write to Nicholas Winning at nick.winning@wsj.com

Subscribe to WSJ: http://online.wsj.com?mod=djnwires