Mexico started Friday's World Cup qualifier at home knowing anything less than a win would mean the best they could hope for was a spot in an intercontinental play-off versus New Zealand.
The home side dominated the match at the Estadio Azteca, and deservedly led 1-0 at half-time through Oribe Peralta, but Panama looked like they might snatch a point when Luis Tejada scored with eight minutes remaining.
With the game in the balance, however, Jimenez stepped up - unleashing a bicycle kick from the edge of the penalty area to score the winner in the 85th minute.
The victory took Mexico above Panama into fourth position in CONCACAF's fourth round standings with 11 points, three behind third-placed Honduras, who sit in the last automatic qualifying spot for next year's World Cup finals with a round of games to play.
Mexico took nine shots to Panama's three in the first half but could only manage the one goal in the 40th minute.
Javier Hernandez, Giovani dos Santos and Javier Aquino had all missed gilt-edged chances to score earlier in the first half.
But Peralta made no mistake with five minutes until half-time when Carlos Pena smashed the ball into the striker's feet and the 29-year-old played a quick one-two with Hernandez before finishing with aplomb.
After half-time, Mexico kept pushing for a second goal and looked likely to double their lead in the 56th minute after Harold Cummings had barged into the back of Aquino, only for Hernandez to hit a limp penalty too close to Panama goalkeeper Jaime Penedo.
The penalty save seemed to inspire Panama and the visitors equalised in the 81st minute with Gabriel Torres chipping the ball through to Jairo Jimenez, who found the back of the net from a tight angle.
But the hosts responded again to pick up their first win at home in World Cup qualifying in five matches, when Fernando Arce took the ball from Hernandez and passed into the feet of Mexican substitute Jimenez for his brilliant winner.
To secure automatic qualification to Brazil 2014, Mexico must defeat Costa Rica away on Tuesday and hope Honduras lose against bottom-side Jamaica, while the Mexicans will also have to make up two goals worth of goal difference.
A draw in Costa Rica will be enough for Mexico to wrap up a spot in the intercontinental play-off versus New Zealand.
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.