WASHINGTON — For President Obama, whose popularity and second-term agenda have been ravaged by the chaotic rollout of the health care law, the preliminary nuclear deal reached with Iran on Sunday is more than a welcome change of subject.

It is also a seminal moment — one that thrusts foreign policy to the forefront in a White House preoccupied by domestic woes, and one that presents Mr. Obama with the chance to chart a new American course in the Middle East for the first time in more than three decades.

Much will depend, of course, on whether the United States and the other major powers ever reach a final agreement with Iran to curb its nuclear ambitions. Mr. Obama himself said Saturday night that it “won’t be easy, and huge challenges remain ahead.”

But the mere fact that after 34 years of estrangement, the United States and Iran have signed a diplomatic accord — even if it is a tactical, transitory one — opens the door to a range of geopolitical possibilities available to no American leader since Jimmy Carter.