At a news briefing on Friday, President Obama said that he spoke by phone with Iranian President Hassan Rouhani, another step in a warming relationship both leaders have said they hope ends with a diplomatic resolution to Iran's controversial nuclear program. (Thomas LeGro/The Washington Post)

Iranian President Hassan Rouhani was on his way to John F. Kennedy International Airport in New York about 2:30 p.m. Friday when the phone rang in his car. President Obama was on the line from the Oval Office, and the two men spoke for 15 minutes, ending a decades-long diplomatic freeze.

No U.S. leader had spoken with an Iranian president since the Islamic revolution ousted the U.S.-backed shah in 1979.

At a news briefing at the White House, Obama told reporters that the two agreed to direct their negotiating teams to seek a deal over Iran’s uranium-enrichment program, which the United States, Israel and other nations believe is cover to develop nuclear weapons. Iranian officials have denied that intent.

“The very fact that this was the first communication between an American and Iranian president since 1979 underscores the deep mistrust between our countries,” Obama said. “But it also indicates the prospect of moving beyond that difficult history.”

Rouhani tweeted out news of the conversation, including that Obama said goodbye in Farsi.

A senior Obama administration official said the tone of the discussion was “cordial,” beginning with Obama’s opening congratulations on Rouhani’s recent election as president.

“The bulk of the call focused on the nuclear issue,” the official said, adding that Obama also expressed concern over two Americans held in Iran and a third who is missing there. “This was about adding momentum to what is already underway.”

The senior official, who talked to reporters on the condition of anonymity, said Iranian officials made clear Friday that Rouhani wanted to speak to Obama before his return to Tehran.

Rouhani had been unwilling to have a brief encounter with Obama when both were at the United Nations this week. A near-handshake highlighted the political challenges Rouhani faces inside Iran, as he seeks to balance the interests of political hard-liners opposed to concessions on the nuclear issue and of those Iranians who elected him and are eager for the economic relief an agreement might bring.

A phone call meant there was no photograph of the two leaders together to irritate Rouhani’s political opponents in Tehran — or to overly encourage his supporters.

Concluding his visit to New York earlier in the day, Rouhani struck a conciliatory note, telling a news conference that he had hoped to accept Obama’s offer to meet this week at the United Nations. But, he said, “the timetable was too short to plan a meeting of two presidents.”

“After 35 years of great tensions between Iran and the United States, and very numerous issues that persist in the relationship, a meeting of the presidents for the first time in this period would naturally come along with certain complications of their own,” Rouhani said.

Obama, who campaigned at some political risk in 2008 on a pledge to directly engage Iran’s leadership, said there were signs to be optimistic that a resolution could be reached. He cited a religious order issued in January by Iran’s supreme leader, Ayatollah Ali Khamenei, against the development of nuclear weapons.

Rouhani was elected in June on a pledge to improve Iran’s relationship with the West and end sanctions that were imposed to pressure the government to open up its enrichment program.

On his first visit to the United Nations this week, Rouhani, in speeches and in meetings, presented a more moderate Iranian leadership eager to end international isolation. Obama indicated Friday that may be possible.

“The test will be meaningful, transparent and verifiable actions, which can also bring relief from the comprehensive international sanctions that are currently in place,” Obama said. “Resolving this issue, obviously, could also serve as a major step forward in a new relationship between the United States and the Islamic republic of Iran, one based on mutual interest and mutual respect.”

Obama said the leaders agreed that the negotiations would continue through the five U.N. veto-holding members and Germany, the international group that has been managing talks in recent years.

On Monday, Obama hosts Israeli Prime Minister Benjamin Netanyahu, who has cautioned the United States to view Rouhani’s overtures with skepticism. Obama is also facing doubts about his overture to Iran from Senate Republicans, who have warned him not to place too much faith in Rouhani, given the opposition the Iranian president faces at home.

“A path to a meaningful agreement will be difficult,” Obama acknowledged. “And at this point, both sides have significant concerns that will have to be overcome. But I believe we’ve got a responsibility to pursue diplomacy and that we have a unique opportunity to make progress with the new leadership in Tehran.”

The adversarial side of the relationship also continues. U.S. officials said this week that Iranian hackers penetrated an unclassified Navy network in an escalation of cyber activity, causing the Navy to have to patch vulnerabilities.

The hack did not take down any network or cause damage that would warrant an offensive counter­strike, officials said, but did raise concerns that the cyber foe is raising its game even as the Obama administration is seeking to advance talks.

“This was just a case of [adversaries] getting better at trying to penetrate unclassified networks and the Navy having to do something about it,” said one U.S. official, who was not authorized to speak on the record. The hack was first reported by the Wall Street Journal.

The senior administration official said that the White House did not envision future negotiations over Iran’s nuclear program taking place between Obama and Rouhani, and that the process will be led by the international group already in charge of it.

The P5+1, as the international mediating group is known, is scheduled to take up Iran’s nuclear program again next month in Geneva.

“The substance of this discussion is going to take place” at the foreign-minister level, the official said. “This is not a negotiation we expect to take place at the presidential level.”

Rouhani told reporters that the “end goal” of the new approach is to build confidence between the two countries — “step by step” — while protecting the interests of both sides.

Rouhani said the international response to his election, and his visit this week to New York, turned out even better than he had anticipated.

The nuclear talks this week at the United Nations, which brought Secretary of State John F. Kerry and Iranian Foreign Minister Mohammad Javad Zarif together, he said, “was very positive and very hopeful and we hope that these talks will yield in a short period of time tangible results.”

Rouhani also defended himself against allegations that in his past role as Iran’s nuclear negotiator he had boasted about using talks as cover to pursue the development of the country’s nuclear program. Israeli leaders are worried the same is happening this time.

“We have never chosen deceit as a path” to negotiations, he said.

He also insisted that “our government has full authority to hold talks with foreign counterparts when it comes to the nuclear file” and that any deal his government strikes will be supported by the full Iranian leadership.

News of the presidential call drew reactions ranging from puzzlement to praise.

“Perhaps it was a perception that by warmly embracing Rouhani they could empower him back home,” said Ray Takeyh, a former adviser to the Obama administration. But Takeyh, a senior fellow at the Council on Foreign Relations, said he worried that recent conciliatory signals from both countries “could be raising expectations too high,” given the formidable obstacles that must be overcome to reach a nuclear deal.

Supporters of diplomacy with Iran hailed the two presidents for demonstrating a commitment to break through years of ill will and diplomatic deadlock.

“Both leaders have shed the taboo of contact,” said Trita Parsi, president of the National Iranian American Council, a Washington-based nonprofit group. “While the final outcome of this courageous journey remains unknown, both sides have shown the courage and will to travel the diplomatic path towards its final destination.”

Lynch reported from the United Nations. Joby Warrick and Ellen Nakashima in Washington contributed to this report.