Eager to reassure an anxious ally, President Barack Obama on Wednesday affirmed Israel's sovereign right to defend itself from any threat and vowed to prevent Iran from obtaining nuclear weapons.

JERUSALEM — Eager to reassure an anxious ally, President Barack Obama on Wednesday affirmed Israel's sovereign right to defend itself from any threat and vowed to prevent Iran from obtaining nuclear weapons. He said containment of a nuclear-armed Iran was not an option and said the United States would do whatever it takes to prevent Iran from getting "the world's worst weapons."

Meeting with Israeli Prime Minister Benjamin Netanyahu on his first visit to the Jewish state as president, Obama offered his personal commitment that the U.S. would stand by Israel in any circumstances that required it to act to protect its people. He said the U.S. and Israel would start talks soon on a new, 10-year security cooperation package to replace one that expires in 2017.

Obama also pledged to investigate whether chemical weapons were used this week in neighboring Syria's 2-year-old civil war, something he said would be a "game-changer" for current U.S. policy. In addition, he said he would continue to urge Israel and the Palestinians to relaunch the moribund peace process.

Speaking at a joint news conference, Obama and Netanyahu, who have sparred on numerous occasions in the past, presented a united front on Iran.

They stressed repeatedly that all options — including military ones — are on the table to keep Iran from acquiring an atomic weapon if the diplomatic track fails. And they brushed aside apparent differences over when the Iranian nuclear program might reach the point that military action is required.

"We will do what is necessary to prevent Iran from obtaining the world's worst weapons," Obama said, calling a nuclear-armed Iran a threat to Israel, the greater Middle East and the world.

Although Obama did not promise that the United States would act militarily against Iran if Israel decided that must be done, he offered an explicit endorsement for Israel to take whatever unilateral measures it deems necessary to guard against the threat.

"Each country has to make its own decisions when it comes to the awesome decision to engage in any kind of military action and Israel is differently situated than the United States," he said. "I would not expect that the prime minister would make a decision about his country's security and defer that to any another country any more than the United States would defer our decisions about what was important for our national security."

Netanyahu seized on the remarks, saying they were an important demonstration of America's steadfast alliance with Israel and part of making the carrot-and-stick approach a credible option to avoid the use of force.