This was said by Jesus:
Jesus said, “Truly, I say to you, there is no one who has left house or brothers or sisters or mother or father or children or lands, for my sake and for the gospel, who will not receive a hundredfold now in this time, houses and brothers and sisters and mothers and children and lands, with persecutions, and in the age to come eternal life. But many who are first will be last, and the last first.”
The last sentence is a warning against pride — those who seek to have positions of prominence in this life, may end up as nothing in the Kingdom of God, but those who are humble may end up with great reward. Almost identical statements are given in Matthew 20:16; Mark 10:31; Luke 13:30.
Jesus also said something similar in Luke 14:11
For everyone who exalts himself will be humbled, and he who humbles himself will be exalted.”
He is picking up on a common Old Testament theme of God raising up the humble and bringing down the proud. See, for example, Psalm 18:27; Proverbs 18:12; 29:23; Isaiah 2:11,17; 57:15.