(Repeats to change slug)
By Matt Spetalnick
WASHINGTON, July 14 (Reuters) - The sealing of a nuclear pact with Iran marks the biggest foreign policy gamble of Barack Obama's presidency - a legacy-defining achievement that could yet backfire if Tehran exploits any loopholes or escalates tensions in the Middle East.
No other foreign policy challenge bears Obama's personal stamp more than the final nuclear accord reached with Iran on Tuesday, and none poses a more critical test of his doctrine of talking to America's enemies to avoid confronting them.
That policy has already resulted in the restoration of diplomatic ties this month with Communist Cuba, ending more than five decades of hostility. But the potential rewards and perils are far greater for the Iran deal, which offers Obama his best hope of salvaging an otherwise shaky record in the Middle East.
Obama's engagement - sometimes at the level of minute technical detail, according to aides - has contrasted with a more aloof approach toward some other geopolitical problems like Syria's civil war and Ukraine's separatist conflict.
Obama, who came into office in 2009 offering to extend a hand to Iran's leaders if they would "unclench their fist", secured a historic opening with a phone call to the Islamic Republic's president and then exchanged secret letters with its Supreme Leader, the Ayatollah Ali Khamenei.
As talks came down to the wire in Vienna, Obama was on the phone to Secretary of State John Kerry regularly from Washington, at least once by secure video link, giving "guidance" to the negotiating team, as the White House put it.
Speaking at the White House, Obama sought to pre-emptively discredit any efforts to derail the agreement by insisting that "no deal means a greater chance of more war in the Middle East." He said his diplomatic approach was the best way to coax Iran away from "the path of violence and rigid ideology," though he acknowledged it would not be easy.
But if the critics are proven right, Obama could go down in history as the president who only bought time before allowing Tehran to go nuclear. That could spark a regional arms race.
Obama, who controversially won the Nobel Peace prize barely nine months into his first term, must overcome accusations from hawkish lawmakers that he abandoned many of his original "red lines" and compromised on others.
Initial U.S. demands dropped along the way included fuller dismantling of Iran's nuclear architecture and rollback of its ballistic missile program. As details emerged on Tuesday, opponents complained that Obama also made concessions on inspection of military sites - although Iran too appeared to have given ground on the issue.
Obama "got what he wanted," said Aaron David Miller, a former Middle East negotiator for Republican and Democratic administrations. "But Iran got more."
Much work remains for Obama to entrench the deal, which lifts sanctions on Iran in exchange for limits on its nuclear work that the West has suspected was aimed at creating a nuclear bomb. Iran denies it has been seeking a bomb.
He must now convince a skeptical Congress not to sabotage the agreement while reassuring allies such as Israel and Saudi Arabia who fear that, once freed from economically crippling sanctions, Iran will be empowered to expand regional influence.
With the possibility of a Republican winning the presidency in 2016, Obama must try to ensure that his successor does not scrap the agreement.
White House aides say critics' demands for a better deal were unrealistic, and Obama declared on Tuesday it would have been "irresponsible" to walk away from it.
The most immediate challenge for Obama will be to clear the obstacles in the Republican-controlled Congress, which will have 60 days to review the Iran agreement.
"The president will have to work harder than ever to explain what the deal actually does, how it blocks the nuclear pathways and what happens if Iran cheats," said Dennis Ross, Obama's former top Middle East adviser.
If Congress votes down the accord, Obama would veto the "disapproval" legislation and then likely have enough votes from fellow Democrats to make it stick. But resorting to such a move would underscore the deal's unsteady footing in Washington.
The international talks among six major powers and Iran to curb Iran's nuclear program in return for eased sanctions were initiated after a telephone call between Obama and newly elected Iranian President Hassan Rouhani on Sept. 28, 2013.
The deal is the biggest step toward rapprochement between Iran and the West since the 1979 Islamic Revolution and may open new ways to address one of the root causes of tension in the region. Shi'ite Iran has a big hand in sectarian conflicts ranging from Syria to Iraq to Yemen.
Critics say Obama's drive to limit U.S. military engagement in the Middle East, most notably a failure to enforce his "red line" on chemical weapons use in Syria in 2013, was seen by Iran's nuclear negotiators as a sign of weakness.
By contrast, President Richard Nixon's unquestioned anti-communist credentials helped immunize him from criticism at home and shored up trust in his commitment to act from strength when he made a historic opening to China in the early 1970s.
Many fear that even if Iran does not covertly work toward a bomb it would remain a nuclear-weapons threshold state able to race ahead once restrictions on its uranium enrichment activities begin expiring in a decade.
That could leave a future U.S. administration with the decision whether to go to war to stop it.
Additional reporting by Warren Strobel and Patricia Zengerle in Washington and Arshad Mohammed in Vienna; editing by David Storey and Stuart Grudgings