The City striker’s third goal for his country sealed top spot in Group C and a clash with Australia in the knockout stages on Saturday.
Alvarez was given his first World Cup start after making a big impact from the bench in Argentina’s win over Mexico in their second group game.
Needing a win to guarantee their progress after a shock defeat to Saudi Arabia in their opening game, nerves were beginning to build after a goalless first half.
But Brighton’s Alexis Mac Allister fired La Albiceleste ahead before Alvarez scored a brilliant second with a fierce curling drive into the top corner in the 68th minute.
The 22-year-old had gone close to opening the scoring in the 35th minute when he raced clear of the Poland defence but his shot was kept out by Wojciech Szczesny.
From the rebound, he picked out Messi at the far post and, following a VAR check, the seven-time Ballon d’Or was adjudged to have been fouled by Szczesny after heading wide.
However, the Polish keeper made amends when his strong arm turned away Messi’s spot-kick.
But he was beaten less than 60 seconds after the restart when Mac Allister turned in Nahuel Molina's low cross before Alvarez put the game beyond doubt.
Alvarez went close to adding a second but fired into the side-netting before he was withdrawn with the game won.
Poland also progressed and will face France in the last-16 with the winner facing England or Ecuador in the quarter-finals.