Despite being deemed fit to play by coach Gerardo Martino, Messi was named among the substitutes in Chicago, but the captain came off the bench and took the game by storm to seal Argentina's passage through to the knockout round of the centenary tournament at Soldier Field.
Defender Nicolas Otamendi had given Argentina a seventh-minute lead and after Panama's Anibal Godoy saw red just past the half-hour mark, Messi utilised his team's numerical advantage within eight minutes of his introduction in the 68th minute.
Messi brought the crowd to their feet 10 minutes later with an exquisite free-kick and he completed his scoring three minutes from time for his 53rd international goal, moving to within three of the all-time record held by Gabriel Batistuta.
And substitute Sergio Aguero scored from close range in the 90th minute as the spirited Panama side were blown away in the second half.
Back-to-back wins saw Argentina improve to six points, meaning the 14-time Copa winners cannot be eliminated as defending champions Chile and Panama sit three points adrift ahead of their final-game fixture.
Argentina were unchanged from their 2-1 win over Chile last week, with Messi once again named among the substitutes.
Hernan Gomez drafted in Luis Henriquez and Valentin Pimentel at the expense of Harold Cummings and Gabriel Torres following Panama's thrilling 2-1 victory against Bolivia.
Argentina raced out to a seventh-minute lead thanks to an unlikely source in centre-back Otamendi.
The outstretched Manchester City defender headed home Angel Di Maria's free-kick at the back post for his second international goal.
But Panama refused to be overawed, despite the scoreline and the quality of opposition, with the CONCACAF nation getting in behind Argentina on numerous occasions.
Panama's hopes, though, were dealt a blow in the 20th and 31st minutes.
Striker Pimentel was forced from the field on a stretcher after appearing to hyperextend his knee as he attempted to latch on to a free-kick, while midfielder Godoy saw red for a second yellow card after an off-the-ball incident, appearing to catch Augusto Fernandez in the face.
Chants of 'Messi' then echoed throughout the stadium after Di Maria succumbed to injury on the stroke of half-time, but Erik Lamela was summoned instead three minutes before the break.
Gonzalo Higuain - fresh from breaking Serie A's goalscoring record in a second season with 36 for Napoli in 2015-16 - had golden opportunity to double Argentina's lead in a one-v-one situation 10 minutes into the second half, but after taking one touch too many, Miller was able to slide in and make a last-ditch tackle.
With the result far from certain, Martino introduced Messi on the hour-mark to a thunderous reception.
It took eight minutes for the skipper to make his presence felt, Messi pouncing on a defensive error to coolly place the ball beyond Jaime Penedo, and the Barcelona star was ait again in the 78th minute, this time curling a free-kick into the top corner of the net.
Messi scored another in the 87th minute, weaving his way in behind Panama's defence and substitute Aguero capped the rout three minutes later, with Messi involved in the build-up.