Iran and six major world powers reached a nuclear deal on Tuesday, capping more than a decade of negotiations with an agreement that could transform the Middle East.
But both leaders face scepticism from powerful hardliners at home after decades of enmity between nations that referred to each other as "the Great Satan" and a member of the "Axis of Evil".
Rouhani was quick to present the deal as a step on the road towards a wider goal of international cooperation. The deal "shows constructive engagement works", he tweeted. "With this unnecessary crisis resolved, new horizons emerge with a focus on shared challenges."
For Obama, the diplomacy withIran, begun in secret more than two years ago, ranks alongside his normalization of ties with Cuba as landmarks in a legacy of reaching out to enemies that tormented his predecessors for decades.
While the main negotiations were between the United States andIran, the four other U.N. Security Council permanent members, Britain,China,FranceandRussia, are also parties to the deal, as isGermany.
Israeli Prime Minister Benjamin Netanyahu called the deal "a bad mistake of historic proportions".
"Iranwill get a jackpot, a cash bonanza of hundreds of billions of dollars, which will enable it to continue to pursue its aggression and terror in the region and in the world," he said. "Iranis going to receive a sure path to nuclear weapons."
Israeli Deputy Foreign Minister Tzipi Hotovely called the deal an "historic surrender". She said on Twitter thatIsraelwould "act with all means to try and stop the agreement being ratified", a clear threat to try to use its influence to block it in the Republican-controlled U.S. Congress.
Congress has 60 days for a review, though if it rejects the deal, Obama can use his veto. It would require two- thirds of lawmakers to override such a veto, which means some of Obama's fellow Democrats would have to rebel against one of their president's signature achievements in order to kill the deal.
Iranis not likely to receive many of the benefits from the lifting of sanctions until next year because of the need to ratify the deal and verify its implementation.
“Celebrating too early can send a bad signal to the enemy,” Iranian conservative lawmaker Alireza Zakani was quoted as saying in parliament by Fars News agency.
He noted that Iran's National Security Council would also review the deal, "and if they think it is against our national interests, we will not have a deal", he said. "The Islamic Republic will not sign a bad deal.”
The final round of talks in Vienna involved nearly three weeks of intense negotiation between U.S. Secretary of State John Kerry and Iranian Foreign Minister Mohammad Javad Zarif.
It was something that would until recently have been unthinkable for two countries that have been bitter enemies since 1979, when Iranian revolutionaries stormed the U.S. embassy in Tehran and held 52 Americans hostage for 444 days.
"NEW CHAPTER OF HOPE"
"I believe this is an historic moment," Zarif, who was educated in the United States and developed a warm rapport with Kerry, told a news conference. "Today could have been the end of hope on this issue, but now we are starting a new chapter of hope. Let's build on that."
European Union foreign policy chief Federica Mogherini, who acted as coordinator for the powers, said: "It is a decision that can open the way to a new chapter in international relations and show that diplomacy, coordination, cooperation can overcome decades of tensions and confrontations.
"I think this is a sign of hope for the entire world."
Hatred of the United States has been a defining trait of Iran's ruling system, on display last week when it marked the last Friday of the Ramadan fasting month with an annual day of protests, crowds chanting "Death toIsrael!" and "Death to America!".
Obama first reached out to Iranians with an address in 2008, only weeks into his presidency, offering a "new beginning".
Iranhas long denied it is seeking a nuclear weapon and has insisted on the right to nuclear technology for peaceful means, although Western powers feared the enriched uranium that it was stockpiling could be used to make a bomb. Obama never ruled out using military force if negotiations failed.
Iran's IRNA news agency said billions of dollars in frozen funds would be released under the deal, and sanctions on its central bank, national oil company, shipping and airlines would now be lifted.
According to a text of the agreement published by the Russian Foreign Ministry,Iranwill retain the right to conduct research into enriching uranium for 10 years, without stockpiling it.
"SNAPBACK MECHANISM" FOR SANCTIONS
Western diplomats saidIranhad accepted a "snapback" mechanism, under which some sanctions could be reinstated in 65 days if it violated the deal. A U.N. weapons embargo is to remain in place for five years and a ban on buying missile technology will remain for eight years.
Alongside the deal, theUnited Nationsnuclear watchdog, the International Atomic Energy Agency, announced an agreement withIranon a road map to resolve its own outstanding issues with Tehran by the end of this year.
The main deal with the world powers depends on the IAEA being able to inspectIranian nuclear sites and onIrananswering the watchdog's questions about the possible military aims of previous research.
The prospect of an agreement benefitingIranis anathema to U.S. allies in the Middle East. Tehran does not recognizeIsraeland supports its enemies. And Arab states ruled by Sunni Muslims, particularly Saudi Arabia, believe that Shi'ite MuslimIransupports their foes in wars in Syria, Yemen and elsewhere.
But there is also a strong reason for the United States to improve its relations withIran, as the two countries face a common foe in Islamic State, the Sunni Muslim militant group that has seized swathes of Syria and Iraq.
ForIran, the end of sanctions could bring a rapid economic boom by lifting restrictions that have drastically cut its oil exports, and have shrunk itseconomyby about 20 percent, according to U.S. estimates. The prospect of a deal has already helped push down global oil prices because of the possibility that Iranian supply could return to the market.
Oil prices tumbled more than a dollar on Tuesday after the deal was reached.
"Even with an historic deal, oil fromIranwill take time to return, and will not be before next year, most likely the second half of 2016," Amrita Sen, chief oil analyst at London-based consultancy Energy Aspects, told Reuters. "But given how oversupplied the market is with Saudi output at record highs, the mere prospect of new oil will be bearish for sentiment."