(Pier Paolo Cito ~ Associated Press)
At the Aida refugee camp, the pope spoke in the shadow of the massive concrete barrier that divides Israelis and Palestinians and urged both sides to resist the urge for revenge and find the courage needed for peace.
The high-profile visit provided a forum for Palestinians to vent their rage over the Israeli occupation, and Benedict said he understood their frustration.
But he urged young people in particular to "have the courage to resist any temptation to resort to acts of violence or terrorism," his first mention of terrorism since he began his Middle East tour last Friday.
At each stop during his 10-hour stay in the West Bank, Benedict said much of what the Palestinians were hoping to hear, including giving assurances of his "deep compassion and remembrance in prayer" for those killed by the Israeli offensive in Gaza.
Arriving in Bethlehem from nearby Jerusalem, Benedict, 82, was driven through a gate in the 25-foot-high concrete wall, part of the separation barrier Israel has erected along the West Bank and calls key to its security.
"Our pope is our hope" read posters hung around the town, also dotted with yellow and cream flags of the Vatican and red, black, white and green Palestinian flags.
At the nearby Aida refugee camp, the pope said the barbed wire and concrete structure served as a "stark reminder" of the tense situation.
The refugee camp, where about 5,000 Palestinians live, is next to the towering wall, and residents had wanted Benedict to speak from a stage next to it to highlight life under Israeli occupation.
But the Israeli government ordered a halt to construction of the stage, saying organizers lacked the necessary permits and the site's proximity to the wall posed a security risk.
"Even if walls can easily be built, we know they don't last forever. They can be demolished," the German-born pontiff told the crowd.
"First of all, however, it is necessary to remove the walls that we build around our hearts," he said.
Israel constructed the barrier to keep out Palestinian attackers, but Palestinians object because it cuts them off from Jerusalem and juts into their land.
Benedict said he regretted the reality that led to its construction.
"In a world where more and more borders are being opened up ... it is tragic to see walls still being erected," he said. "How earnestly we pray for an end to the hostilities that have caused this wall to be built."
Referring to the pope's remarks, Israeli government spokesman Mark Regev said: "We did not want to build a security barrier. We were forced to by the continuous infiltration of suicide bombers entering our country and murdering our people. We wish the reality were different."
At the refugee camp, a group of Palestinian children in traditional dress danced for the pope, first to the notes of Beethoven's Fifth Symphony and then to an upbeat song in Arabic, as scenes of the West Bank played on huge screens behind them.
Some of the children held oversized black keys -- a symbol associated with the homes refugees left behind during the two-year war that followed Israel's creation in 1948. One of the most sensitive issues in Israel-Palestinian negotiations has been the demand that Palestinians be allowed to return to property in what is now Israel.
The pope finessed the Palestinian demand that they be allowed to take back abandoned property in Israel, expressing solidarity with "all the homeless Palestinians who long to be able to return to their birthplace, or to live permanently in a homeland of their own." Hundreds of thousands of Palestinians still live in refugee camps six decades after they lost their homes in what is now Israel.
Earlier, the pope received a red-carpet welcome to Bethlehem from Palestinian President Mahmoud Abbas, who denounced Israeli occupation policies, singling out what he labeled the "apartheid wall."
A year of U.S.-backed peace talks that started in November 2007 yielded no discernible results, and Israel's new leader, Benjamin Netanyahu, has criticized the format of the negotiations.
At the refugee camp, Benedict said, "It is understandable that Palestinians feel frustrated," adding that "their legitimate aspirations for permanent homes, for an independent Palestinian state, remain unfilled."
In his homily in Manger Square, packed with 10,000 people on a mild, sunny day in front of the Church of the Nativity, Benedict urged Palestinians to keep alive the "flame of hope" for a "sovereign Palestinian homeland in the land of your forefathers, secure and at peace with its neighbors, within internationally recognized borders." He upgraded the reference to "state" in another appearance.
The Vatican has long supported a Palestinian state -- expressed by Pope John Paul II in the same Manger Square during his historic Holy Land pilgrimage nine years ago -- but Netanyahu's reluctance to endorse the concept has thrown peace efforts into doubt.
Benedict also delivered a special message of solidarity to the 1.4 million Palestinians isolated in Hamas-ruled Gaza, saying: "In a special way, my heart goes out to the pilgrims from war-torn Gaza."
He later met with a small group of Christians who got permits to cross Israel from Gaza to reach Bethlehem in the West Bank. He has no plans to visit Gaza.
Earlier this year, Israel waged a three-week war against Gaza militants that killed more than 1,150 people and badly damaged thousands of homes. The war compounded suffering from an Israeli and Egyptian blockade of Gaza's borders, imposed after Hamas wrested control of Gaza two years ago.
Benedict also met with families of two Palestinian prisoners held by the Israelis, one Christian and the other Muslim, the Vatican spokesman said, explaining it followed a meeting Benedict had with the family of a captured Israeli soldier.
Christians are a tiny minority among the 3.9 million Palestinians who live in the West Bank and Gaza Strip. In a trend seen throughout the Middle East, their numbers have dwindled as Palestinians weary of occupation seek out new opportunities abroad.
"When he comes and visits us, it gives us moral and material support," said Ramzi Shomali, a 27-year-old electric company worker. "It motivates us to stay in our land."
The pontiff brought several gifts to Bethlehem, including a ventilator for a children's hospital and a mosaic representation of the birth of Jesus. He received a handwritten Gospel of Luke.
Associated Press writers Diaa Hadid, Dalia Nammari, Ben Hubbard and Mohammed Daraghmeh contributed to this report.