Obama's visit was part of a nine-day trip abroad that has drawn intense news coverage, sparking complaints of media bias from McCain's campaign. Obama plans stops in Berlin, Paris and London before he flies home Saturday.
In Jerusalem, Obama paid a solemn visit to Yad Vashem, the Israeli Holocaust museum. Wearing a yarmulke, he laid a white flower wreath on a stone slab that covers the ashes of Jews killed by the Nazis.
"Let our children come here and know this history, so they can add their voices to proclaim, 'Never again,' " he wrote in the museum's guest book.
When he left the city early this morning, Obama briefly visited the Western Wall, where he followed custom and tucked a note with his prayers into a crack between the stones.
Security for Obama's trip was tight. Hours before his arrival Tuesday, a Palestinian man went on a rampage with a construction vehicle, wounding six people just outside the candidate's Jerusalem hotel. At the museum, Obama met with Amal Ganem, an Israeli border police officer who, along with an armed Israeli civilian, shot and killed the assailant.
Obama spent much of his day with Israeli leaders, starting with Defense Minister Ehud Barak, who heads the Labor Party, and Netanyahu.
"He is trying to cover a large array of items on the Israeli-U.S. agenda," said Isaac Herzog, an Israeli Cabinet minister who attended the meeting with Barak. "He is a new player in the region, so we are definitely pleased that he's seeing so much on the ground."
Obama also met with Peres at his home. Peres urged him to strive "to be a great president."
"Senator, I have read your two books and was moved as a human being," he told Obama at the start of their meeting.
From there, Obama headed to Ramallah, the West Bank administrative capital. Dozens of armed Palestinian security forces lined the road to the compound where he met Abbas and his prime minister, Salam Fayyad. On the wall behind them were photos of late Palestinian leader Yasser Arafat.
In Israel, the country's political instability worked in Obama's favor, with some of those angling for power maneuvering to be shown on TV with the senator. Olmert, who ate dinner with Obama on Wednesday, may be forced out from the prime minister's job on corruption charges before the next U.S. president is inaugurated.
Like Netanyahu, two of Olmert's top ministers, Barak and Foreign Minister Tzipi Livni, are among those who hope to succeed him. The pair scrambled to serve as Obama's guide in Sderot. In the end, both escorted him on a helicopter tour of Israeli areas that have come under attack by rockets fired from Gaza.
After surveying Jerusalem's holy sites, including the Dome of the Rock and the Western Wall, they flew to the West Bank border area, back over Tel Aviv, then along the Mediterranean coast to Sderot.
In Sderot, Obama visited a family whose home was destroyed by a rocket.
"The fact that you came to Sderot shows something not only to Sderot," Livni told Obama at the police station, "but to the entire state of Israel."
Special correspondent Maher Abukhater in Ramallah and Times staff writer Maeve Reston in Wilkes-Barre, Pa., contributed to this report.