Panama looked set to hold on for a draw with goalkeeper Oscar McFarlane having made seven saves before the goal but Torres smashed the ball home in the 89th minute after the Panamanian shot-stopper had failed to hold onto Miguel Herrera's shot from outside the box.
The win was Mexico's third in a row, after a friendly victory over Honduras on Thursday and success against Bolivia in September.
The hosts had far better of the goal-scoring opportunities, taking 16 shots to Panama's three at the Estadio La Corregidora.
But McFarlane made a number of fine stops to keep the visitors in the contest until Torres' late strike decided the match.
Mexico moved the ball out to the right and Herrera burst forward before unleashing a strike from 20 yards that bounced in front of McFarlane and deflected off the goalkeeper's midriff.
Oribe Peralta leapt highest to get his head to the loose ball and flicked it to Torres, and the Chivas USA striker volleyed into the net from six yards.
Mexico's next match will be a friendly away to Netherlands, while Panama host El Salvador - both matches taking place in November.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.