By Philip Pullella and Wojciech Zurawski

KRAKOW, Poland (Reuters) - Pope Francis on Saturday condemned the "devastating wave of terrorism" and war that has hit the world and urged a huge crowd of young people not to be indifferent to the suffering of others.

The pope, who ends his five-day trip to Poland on Sunday, made an unscheduled stop at the church of St. Francis of Assisi in Krakow to recite a prayer for peace.

"Touch the hearts of terrorists so that they may recognize the evil of their actions and may turn to the way of peace and goodness, of respect for the life and for the dignity of every human being, regardless of religion, origin, wealth or poverty," he said in the prayer.

When he started the trip on Wednesday, Francis said the killing of an elderly priest in France by suspected Islamist militants and a string of other attacks were proof the "world is at war" but that it was not caused by religion.

From the church Francis went to a large field outside the city where he addressed hundreds of thousands of young people in Krakow for an international gathering of Catholic youth.

There, after watching dance representations of stories of struggle, conflict and redemption, he heard a young representative from Aleppo, Syria, say "God, where are you? Do you exist?"

In response, Francis asked the young people to pray for Syria and other places in conflict and said: "Once and for all, may we realize that nothing justifies shedding the blood of a brother or sister."

He urged those who are better off not to remain remote from the suffering of others. "The times we live in do not call for young 'couch potatoes'," he said.

Earlier on Saturday, Francis addressed Polish priests and bishops, urging them to live simpler lives, focus on those most in need and shun worldly ambitions.

In the homily of a Mass, he told them not to lead "two-track lives" or to "remain enclosed, out of fear or convenience, within ourselves ..."

Some media commentators have accused Polish Church leaders of enjoying a lifestyle protected from the difficulties some Poles are facing in the economic transition from communism to capitalism.

Francis spoke to the bishops at a modern shrine to the memory of the late Pope John Paul and built on a site of a stone quarry on the outskirts of Krakow where German occupiers forced the future pontiff to work during World War Two.

Francis' five-day trip to Poland has taken place in the shadow of the Polish pontiff, who has cult-like status in Poland for his role in inspiring his native country to stand up to communist rule in the 1980s.

The shrine houses relics of the late pope, such as the blood-stained white cassock he was wearing on May 13, 1981, when he was shot and nearly killed by Turkish gunman Mehmet Ali Agca in St. Peter's Square in the Vatican.

(Additional reporting by Wiktor Szary; Editing by Ruth Pitchford and Richard Balmforth)