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 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. 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 U.S. leader since Jimmy Carter.

“No matter what you think of it, this is a historic deal,” said Vali R. Nasr, dean of the Johns Hopkins School of Advanced International Studies. “It is a major seismic shift in the region. It rearranges the entire chessboard.”

Obama has wanted to bring in Iran from the cold since he was a presidential candidate, declaring in 2007 that he would pursue “aggressive personal diplomacy” with Iranian leaders, and ruling out the concept of leadership change, which was popular at the time.

But the president has sought to avoid being consumed by the Middle East, in part so he could shift America’s gaze to Asia. He has tended to view Iran through two narrower prisms: his goal of curbing the spread of nuclear weapons and his desire to avoid entangling the United States in another war in the region.

Friday, Obama huddled in the Oval Office with Secretary of State John F. Kerry over the fine points of a proposal to the Iranians. He was intent on making sure that Iran halted all testing at a heavy-water reactor, a senior administration official said, and in tying any reference to Iran’s enrichment of uranium only to a final agreement.

Still, pursuing a broader diplomatic opening, Nasr said, could alter other U.S. calculations in the region – from Syria, where the Iranian-backed group Hezbollah is fighting alongside President Bashar Assad’s government, to Afghanistan, where the Iranians could be helpful in brokering a postwar settlement with the Taliban.

The prospect of such a long-term strategic realignment is precisely what has so alarmed U.S. allies such as Saudi Arabia, the Persian Gulf emirates and Israel, whose leader, Prime Minister Benjamin Netanyahu, on Sunday condemned the deal as a “historic mistake.”

It is also what has stirred opposition from lawmakers, including those of Obama’s party, who complain that the deal eases pressure on Iran without extracting enough concessions.

“It was strong sanctions, not the goodness of the hearts of the Iranian leaders, that brought Iran to the table,” Sen. Charles E. Schumer, D-N.Y., said Sunday.

To some extent, Obama finds himself in a predicament similar to that of his policy toward Syria, where allies like Saudi Arabia favor more robust support of the rebels fighting Assad. Some experts predicted that the tensions over Iran would only deepen because the administration would be determined to prevent the deal from unraveling.

As Obama looks ahead, however, it is not the fine details but the big picture that is likely to dominate his attention. Among the decisions he faces is whether to treat Iran’s nuclear program as a discrete problem to be solved, freeing him up to focus more on Asia, or as the opening act in a more ambitious engagement with Iran that might give it a role in Syria, Afghanistan and other trouble spots.

Aides say that he is open to this but that it will depend on factors that are out of America’s control, such as moderates’ gaining ground in Iran. And given the extreme sensitivities the interim deal has aroused in the Middle East and on Capitol Hill, the White House is being careful to cast the coming negotiations narrowly.

“First and foremost, this has been a multifaceted, multiyear process to address a serious security concern,” said Thomas E. Donilon, former national security adviser to Obama, who coordinated Iran policy before leaving the White House in July.