The Democratic rivals held a televised debate in Philadelphia on Wednesday ahead of the Democratic primary poll in Pennsylvania on April 22.
Obama had earlier pledged to help Israel defend against regional threats, and criticised Jimmy Carter, the former US president, for seeking to meet Hamas leaders while on a trip to the Middle East.
|Hamas is not a state, Hamas is a terrorist organisation|
"Hamas is not a state, Hamas is a terrorist organisation," Obama said at a Philadelphia synagogue on Wednesday.
At the debate, he said: "An [Iranian] attack on Israel is an attack on our strongest ally in the region, one whose security we consider paramount.
"That would be an act of aggression that I would consider unacceptable and the United States would take appropriate action."
Janet McElligott, a political strategist and former official in the administration of former president Bush, told Al Jazeera the issue was not an important one for the US electorate and that the power of the pro-Israel lobby in the US helped magnify for the issue for the campaign.
"Israel pours tons and tons of money into everybody's campaigns and they actually target people for defeat," she said.
However unlike Clinton, the Illinois senator said he would be prepared to hold direct talks with Mahmoud Ahmadinejad, the Iranian president, over the row over Tehran's nuclear programme.
On Thursday, Ahmadinejad described Iran as the "most powerful nation" on earth as the country's air force put on a display outside Tehran.
The Iranian leader also warned that the country's armed forces would respond immediately to any military strike.
The US and Israel, the Middle East's sole undeclared nuclear power, have accused Iran of using its civilian nuclear power programme as a cover for attempting to develop an atomic bomb.
Tehran vehemently denies that the technology used for producing fuel for nuclear power is being used to enrich the uranium to a much higher level to produce a nuclear explosion.