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 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 having to confront 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.