Israel should not negotiate with Hamas so long as the Islamist group poses a threat to Israeli citizens, US Democratic presidential candidate Barack Obama said on Wednesday during his visit to the town of Sderot. Obama said that if someone were firing on his home, where his two daughters were sleeping, he would do everything to stop the attacks – and that this is how he expects Israel to act as well. During his brief visit to Sderot Obama also noted the terror attack in Jerusalem on Tuesday, Hizbullah attacks and the Iranian nuclear program, saying that all of these were genuine threats Israel faces alongside the Qassam rockets from Gaza. At a press conference held towards the end of his visit, Obama was presented with an 'I love Sderot' t-shirt by the town's mayor, Eli Moyal. ''America must always stand up for Israel's right to defend itself against those who threaten its people,'' he said. Earlier in the day the visiting senator said a nuclear Iran would pose a "grave threat" and Tehran's nuclear program poses a problem for all of humanity. Obama, who is in Israel as part of an overseas tour aimed at bolstering his foreign policy credentials, pledged staunch support for Israel and said that if elected, he would work to reinvigorate the Middle East peace process. "A nuclear Iran would pose a grave threat and the world must prevent Iran from obtaining a nuclear weapon," Obama told reporters after leaving Sderot, a small town near the Gaza border and a frequent target of Palestinian terror groups. Obama examines Qassam shell (Photo: AFP) Later on Wednesday Obama met with Jerusalem Mayor Uri Lupolianski. The mayor was accompanied by two of the victims from Tuesday's bulldozer attack. Lupolianski told Obama that while he does not worry that anyone will divide Jerusalem, "talk of doing so may encourage terrorism." Obama said that he stands behind Israel and was moved by the stories of the two attack victims. He told the mayor there was no room for more fences in Jerusalem. 'Here to reaffirm the special relationship' Obama met Israeli Defense Minister Ehud Barak and Opposition leader Benjamin Netanyahu, after which he visited the Yad Vashem Holocaust Museum. A visibly emotional Obama toured the Holocaust memorial, saying he always finds himself wondering how humanity could have produced such evil. He then thanked the Israeli people for building Yad Vashem, saying it creates a climate of hope for a better world. "At a time of great peril and torment, war and strife, we are blessed to have such a powerful reminder of man's potential for great evil, but also our capacity to rise up from tragedy and remake our world," he wrote in the visitors' book. The presidential hopeful later met with President Shimon Peres in Jerusalem. "I'm here on this trip to reaffirm the special relationship between Israel and the United States and my abiding commitment to Israel's security and my hope that I can serve as an effective partner, whether as a US senator or as president," Obama said during the meeting. Obama, who faces Republican John McCain in the November election, is struggling to overcome wariness among some Israelis and some Jewish voters in the United States about the strength of his commitment to Israel. Obama at Yad Vashem (Photo: AFP) But he also dismayed Palestinian leaders when he said last month that Jerusalem should be Israel's "undivided" capital. Palestinians want Arab East Jerusalem, as the capital of a future state. Obama later said he used "poor phrasing" when he made the remarks. The itinerary of the Democratic candidate, an Illinois senator, also includes a visit to the occupied West Bank to meet Palestinian President Mahmoud Abbas and Prime Minister Salam Fayyad. 'He started out with one big strike against him' Obama arrived in Israel just hours after a Palestinian rammed a bulldozer into vehicles on a busy Jerusalem street near the hotel booked for his stay. The attacker wounded at least 16 people, one seriously, before being shot dead. At the airport, Obama said the bulldozer attack was "just one reminder of why we have to work diligently, urgently and in a unified way to defeat terrorism". Prior to his trip to Israel, Obama visited Iraq and Afghanistan as part of a fact-finding tour and underscored his goal of bringing US troops home within 16 months and stepping up a focus on Afghanistan. Obama plans to visit Berlin, Paris and London after Israel. Just after visiting Iraq, Obama told reporters in Amman he would work vigorously for a peace deal between Israelis and Palestinians but said it would not be easy. "My goal is to make sure that we work, starting from the minute I'm sworn into office, to try to find some breakthroughs," Obama said, adding that it was unrealistic to expect a US President to "suddenly snap his fingers and bring about peace". Obama will stop on Wednesday in the Israeli town of Sderot, which sits near the border with the Gaza Strip and has been hit by cross-border rocket attacks. The rocket attacks, and Israeli military operations in the territory, have largely subsided since an Egyptian-brokered ceasefire took hold last month.