JERUSALEM (CBSDC/AP) — President Barack Obama is warning Iran that the U.S. will “do what is necessary” to prevent Tehran from acquiring nuclear weapons.

Obama spoke after meeting Wednesday in Jerusalem with Israeli Prime Minister Benjamin Netanyahu.

“All options are on the table” in dealing with Iran, Obama said. “We will do anything to make sure Iran doesn’t get a nuclear weapon.”

Despite all options being on the table, Obama still believes the best way to make sure Iran doesn’t acquire a nuclear weapon is through sanctions.

“It will be in everybody’s interest … if this gets resolved diplomatically,” Obama said.

Netanyahu backed Obama, saying the president is determined to make sure Iran won’t get a nuclear weapon.

“Iran is a grave threat to Israel, a grave threat to the world,” Netanyahu said.

Netanyahu added that Israel will defend itself in the case of an attack by the Tehran regime.

“Israel has a right to independently defend itself against any threat, including an Iranian threat,” Netanyahu said.

Obama said he would not expect Israel to defer its security decisions to another country.

The West says Iran’s program is aimed at developing nuclear weapons technology. Iran says its program is for peaceful purposes.

Iran has defied the international community’s urging that it consent to nuclear inspections.

Obama also discussed the current problems between Israelis and Palestinians, saying he’s certain he could have done things differently when it comes to the Mideast.

But he says bringing peace to the region is “a really hard problem” to solve — one that’s lingered for more than 60 years.

Obama also suggests that failure to reach an agreement between the two sides doesn’t mean that he “screwed up somehow.”

Relations between Obama and Netanyahu have soured over how to deal with Iran as the White House wants to deal with the Tehran regime diplomatically while the Israeli prime minister warns they will take military action to strike Iran’s nuclear facilities.

Obama arrived in Israel on Wednesday for his first visit as president to the Mideast ally.

(TM and © Copyright 2013 CBS Radio Inc. and its relevant subsidiaries. CBS RADIO and EYE Logo TM and Copyright 2013 CBS Broadcasting Inc. Used under license. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.)