In a cauldron of noise at Lusail Stadium, Messi and Argentina knew defeat would end their hopes of reaching the last 16 after only two games following the stunning loss to Saudi Arabia in their opener.
The tension was mounting as Mexico frustrated Messi in an attritional game, especially in a first half littered with fouls and stoppages that never allowed Argentina to gain any momentum.
Messi changed all that after 64 minutes when he took one touch to control a pass with his left foot before drilling an unerring finish past Mexico keeper Guillermo Ochoa into the bottom corner from 20 yards.
The masses of Argentina supporters in a crowd of 88,966 went wild in celebration and relief as their World Cup campaign got back on track.
Enzo Fernandez added a superb second with a curling shot into the top corner three minutes from time but it was Messi who made the breakthrough and the difference.
Victory in a tough final Group C game against Poland will send them into the knockout phase.
It was when the game settled down, the stoppages reduced and a football match broke out that Messi was finally able to exert his influence, wandering far and wide on the vast expanse of Lusail Stadium before finally making the decisive contribution.
In an ear-splitting atmosphere, Messi turned up the volume even more with that breakthrough goal that finally broke Mexico down and reignited Argentina’s World Cup.
Messi produced two perfect touches with that wand of a left foot, one to control and one to arrow a finish beyond Ochoa’s outstretched left hand.
It was what all of Argentina hoped for and demanded from their great talisman and, as so often before for club and country, the 35-year-old produced when they needed him most.
This highly-touted side had faced real jeopardy. Argentina knew defeat would finish them here in Qatar. Messi knew defeat would end his dream of lifting the World Cup, the major honour missing from his glittering and extensive honours list.
He followed another superstar in Kylian Mbappe, whose two goals against Denmark put France into the last 16, and he showed here he is determined not to be outshone by the other members of his elite group.
Mexico, backed by their own massed ranks of fans, were in no mood to step aside and it took that big moment to unlock them, bowing to Messi as so many others have done before.
There is still work to do for Argentina when they face Group C leaders Poland, who boast a sporting icon of their own in striker Robert Lewandowski, but the celebrations at the final whistle gave the impression that a team hotly tipped to lift the World Cup at this same Lusail Stadium believe their show is now on the road thanks to their captain and resident genius.