TRUJILLO, Peru (Reuters) - Pope Francis, visiting an area of Peru that was devastated last year by heavy rains linked to climate change and plagued by gang violence, urged people not to lose hope.

On his penultimate day in Peru, Francis flew north to the this city near the Pacific Ocean to say Mass for about 200,000 people on the beach at the nearby oceanside town of Huanchaco.

“Peruvians today do not have the right to lose hope,” he said in improvised comments in his homily to the vast crowd from his vantage point on a huge altar overlooking the Pacific.

Trujillo, capital of the region of La Libertad, was hit by major floods after six landslides in less than a week at the beginning of 2017, leaving tens of thousands of people homeless. The vast majority of people affected were poor.

The disaster was caused by the climatic phenomenon called Niño Costero, a warming of surface waters on the Pacific Ocean that generates intense rains on the coast of South America. Scientists have said climate change will make El Ninos more frequent and intense.

“You know the power of nature, you have experienced its force,” Francis said. “You had to face the brunt of the ‘Niño Costero’ whose painful consequences are still present in so many families, especially those who are not yet able to rebuild their homes”.

Apocalyptic scenes recorded on cellphones and shared on social media broadened the sense of chaos. Bridges collapsed as rivers breached their banks and cows and pigs turned up on beaches after being carried away by rivers.

Francis, who has often warned about the effects that climate change has on the poor, wrote a major document in 2015 on the need to protect the environment in which he backed scientists who say climate change is at least partially caused by the burning of fossil fuels.

Throughout Peru, an unusually brutal rainy season last year killed at least 162 people, slowed economic growth sharply and caused damage equivalent to 2 percent of Peru’s gross domestic product. The cost of rebuilding damaged infrastructure was expected to be about $8 billion.

Slideshow ( 9 images )

In his homily, Francis also mentioned increasing violence in the Trujillo area, where there have been hundreds of murders related to drug trafficking.

The pope said “organized violence, like contract killings, and the insecurity they breed,” insecure housing, and unemployment were the other “storms” the area had to bear.

Thousands of people spent the night on the beach in tents and sleeping bags waiting for the pope.

“You cannot imagine the enthusiasm we have for the pope, our faith is so great that it makes us forget the cold and fatigue in this vigil,” said Roger Montañez, 56, who was wrapped in a blanket to protect from the ocean breeze.