The Etihad striker was introduced with the score goalless and Argentina struggling to make an impact in their second Group C clash.
Within 60 seconds of Alvarez’s arrival, Argentine skipper Messi raised the roof of the Lusail Iconic Stadium as broke the dogged resistance of Mexico by firing home a stunning 20-yard drive.
It was Messi’s sixth consecutive goal for La Albiceleste and eighth World Cup in total - and none can have been more important.
Lionel Scaloni’s side then sealed victory four minutes from time as substitute Enzo Fernandez curled home a superb shot
There was a highly charged atmosphere as the Copa America champions and Latin American flag bearers locked horns.
Argentina were seeking to bounce back from last Tuesday’s shock 2-1 loss to Saudi Arabia while Mexico were aiming to build on a goalless draw with Poland in their opening encounter.
And with so much at stake it proved a feisty, fiercely contested match, full on endeavour but low on clear-cut chances and genuine quality for the first hour or so until Alvarez’s entry.
The best opportunity of an attritional first half came on 44 minutes when Argentine and Aston Villa keeper Emi Martinez leapt acrobatically to gather a 20 yard free-kick from Mexican skipper Alexis Vega.
Inspiration proved elusive again after the break until Messi – at 35 years of age in his fifth and likely final World Cup – reminded a worldwide audience of his enduring genius.
Receiving the ball 30 yards out from goal, he took an initial step forward before striking low past Mexico keeper Ochoa inside the left hand upright.
Alvarez then broke at pace down the left edge of the box and almost put Messi in again on 77 minutes as the pair dovetailed to great effect.
And Argentina’s victory was confirmed three minutes from the end through substitute Fernandrez’s sublime first international strike as he shimmed inside the box before despatching a brilliant curling right foot effort.
It means there us everything to play for going into next Wednesday’s final Group C matches.
Poland lead the way with four points, Saudi Arabia and Argentina both have three while Mexico have just one.
Argentina round off their group campaign when they tackle Poland with the Mexicans needing to beat Saudi Arabia and hope the Poles win too.