Some people tugged on his sleeve from behind a barrier, at one stage nearly pulling him over.
After it happened a second time the Pope looked irritated and shouted: "Don't be selfish, don't be selfish."
He tried to step back and a loudspeaker system urged crowds not to group together.
The incident happened after he and others watched young dancers and singers performing in the western city of Morelia, in the state of Michoacan - a region known as the centre of the country's drugs trade.
During the visit he also urged Mexican priests in a special mass not to allow themselves to accept a society dominated by drug-fuelled violence and corruption, but to get out of their comfort zones and fight injustice.