An estimated one million people gathered at a stadium in Madagascar's capital to hear Pope Francis say mass on the second leg of his three-nation African tour.
The massive crowd in Antananarivo had waited patiently, stretching into the distance from the early hours, to see the first pontiff to visit the Indian Ocean island nation in 30 years.
"Organisers estimate there are around one million people," a Vatican spokesman said.
Some described it as the biggest public gathering in Madagascar's history.
Many people wore pope-emblazoned white and yellow caps - the colours of the Vatican, and they cheered as the pope-mobile made its way through wind-swept clouds of red dust picked up from the stadium floor.
During the homily, the Argentine pontiff urged them "to build history in fraternity and solidarity" and "in complete respect for the earth and its gifts, as opposed to any form of exploitation".
He spoke out against "practices that lead to the culture of privilege and exclusion" and criticised those who consider family "the decisive criterion for what we consider right and good".
"How hard it is to follow him (Jesus) if we seek to identify the kingdom of heaven with our personal agenda or... abuse the name of God or of religion to justify acts of violence, segregation and even murder".
In Madagascar - home to 25 million people - the vast majority live in poverty on an income of less than $2 a day. More than half its young people are jobless.
The country ranks 152 out of 180 nations on Transparency International's Corruption Perceptions Index in 2018.
President Andry Rajoelina, who attended the mass with his wife, welcomed the pope's remarks.
"As a Christian and a man of the state, I am fighting relentlessly against corruption, poverty and the ills that plague Madagascar," Mr Rajoelina tweeted. "We act first for the weak."
After mass the pontiff will visit Akamasoa, a city founded by Argentian priest Father Pedro, who has lifted thousands of Malagasy waste-pickers out of poverty.