Worshippers braved the windswept dust to ensure a place at the Mass.
Catholics turned up early in the morning for the service at 10:00 local time to ensure finding a space.
Some even camped out days before.
On Sunday morning, the wind did not let up for the Pope or bishops taking part in the Mass.
Addressing worshippers, the Pope spoke out against what he termed the patronage which produces a few rich people while the vast majority live in grinding poverty.
"When 'family' becomes the decisive criterion for what we consider right and good, we end up justifying and even 'consecrating' practices that lead to the culture
of privilege and exclusion: favouritism, patronage and - as a consequence - corruption", he said in his homily.
Many people wore white and yellow - the colours of the Vatican - and some even received communion while wearing Pope-branded T-shirts.
Some have described it as the biggest public gathering in Madagascar's history.
It is not, however, the Pope's biggest gathering.
That record stands at six million people when Pope Francis celebrated Mass in the Philippine capital Manila in 2015.
Madagascar is the second part of his three-leg Africa tour. He has already visited Mozambique and his next stop is Mauritius.