The pontiff touched on "the globalization of indifference" before he left to return to Rome. The Mass marked a positive end to a six-day trip to Latin America that saw controversy over clergy abuse.
Over a million people flocked to a Peruvian airbase outside Lima on Sunday to attend the final Mass held by Pope Francis before he returned home to Rome.
The event marked the end of the pontiff's sixth trip to Latin America that also included a controversial stop in neighboring Chile.
The 81-year-old pontiff called on followers, some of whom had waited more than 24 hours at the airbase, to defeat "the globalization of indifference" and help those in need.
The pope earlier criticized environmental degradation and endemic corruption in Peru and the rest of Latin America, mentioning graft probes against former Peruvian presidents Ollanta Humala, Alejandro Toledo and Alan Garcia.
"What is happening in Peru, where every president is jailed?" he was quoted as asking by daily La Republica. "If we fall into the hands of people who only understand the language of corruption, we're toast."
Pope Francis also mentioned the case against former president Alberto Fujimori, who current President Pedro Pablo Kuczynski pardoned in December half-way through a 25-year jail sentence for corruption.
Shadow of Chile
The pope arrived in Peru on Thursday after a three-day visit in Chile that saw protests over sexual abuse cases by clergy and his dismissal of abuse-related allegations against Chilean Bishop Juan Barros.
Barros allegedly protected his former mentor, the Reverend Fernando Karadima, who stood down after an internal Vatican investigation found him guilty in 2011 of abusing teenage boys. Barros denied any knowledge of Karadima's actions.
Pope Francis said there was no proof for the accusations and called them "slander." The Archbishop of Boston and a top Vatican advisor on clergy abuse, Cardinal Sean O'Malley, said the pope's words were "a great source of pain for survivors of sexual abuse."
Several churches were set on fire during Pope Francis' trip in Chile, and police fired tear gas at protesters outside a Mass in the capital, Santiago.
'Reasons for hope'
Despite the earlier controversy, the atmosphere at Sunday's farewell Mass in Peru was largely positive and enthusiastic. O'Malley was one of the dozens of clergy celebrating the service with Pope Francis under the huge, tented altar.
The pontiff struck a optimistic tone before leaving, calling on worshippers to remain hopeful and united.
"Dear Peruvian brothers and sisters, you have so many reasons for hope ... There is no better way to protect your hope than to remain united."
amp/jm (dpa, Reuters, AP)