"War never again!" Pope Francis has urged Bosnians as he celebrated Mass in Sarajevo in front of 65,000 people.
The Pope travelled to Bosnia on Saturday to encourage peace and reconciliation across the country, which was devastated by the 1990s war.
He was visibly moved by the testimony of two priests and a nun about their experiences of torture during the war.
The Pope also met members of the Muslim, Orthodox Christian and Jewish communities during his one-day trip.
Bosnia remains divided along religious and ethnic lines, 20 years after the fighting.
"War means children, women and the elderly in refugee camps; it means forced displacement, destroyed houses, streets and factories. Above all countless shattered lives," the Pope Francis said in his homily at Sarajevo's Kosevo stadium.
"You know this well having experienced it here," he added in reference to the 1992-95 conflict, which left some 100,000 dead and two million displaced.
The Pontiff also warned that the world faced "a kind of third world war being fought piecemeal and, in the context of global communications, we sense an atmosphere of war".
The war between Christian Orthodox Serbs and Muslim Bosniaks in the early 90s resulted in deep ethnic divisions. There was also a Bosniak-Croat conflict within the wider war.
Bosnia-Herzegovina's Roman Catholics, from the Bosnian Croatian community, are estimated to number 10-15% of the population.
Their numbers have been depleted by people leaving, both during the war and since. Ethnic Croats in Bosnia are entitled to apply for Croatian passports, which gives them freedom of movement in the European Union.
The Pope spoke to the three-member presidency and called on the country to reject division and continue working for peace to create "a melody of sublime nobility and beauty, instead of the fanatical cries of hatred".
Speaking to reporters on his flight to Sarajevo, he described Sarajevo as the "Jerusalem of the West".
"It is a city of very different ethnic and religious cultures. It is even a city that has suffered much during its history. Now it is on a beautiful path of peace. I am making this trip to talk about this, as a sign of peace and a prayer for peace."
At least 5,000 police were on duty and authorities published a helpline number if members of the public spotted any suspicious activity during the visit.
On Friday local media reported jihadists claiming to be from Islamic State had issued a video, calling for action in the Balkans. However, it is not thought to be linked to the papal visit.
It is 18 years since Pope John Paul II travelled to Sarajevo during a severe snowstorm in 1997. A monument was erected in his honour in 2014.