Needing a win and for Mexico to lose in Costa Rica, Panama looked to have got both results and appeared to be on the verge of snatching the play-off spot in CONCACAF qualifying.
Luis Tejada's 83rd-minute goal looked to have been enough before the USA equalised in the 92nd minute through Graham Zusi.
And Aron Johannsson ensured there would be no chance of Panama reaching their first ever World Cup when he struck a minute later.
Michael Orozco had cancelled out Gabriel Torres' opener earlier on, with Mexico fortuitously falling into the play-off and a tie against New Zealand.
Wet conditions made maintaining possession difficult for both sides early on at the Estadio Rommel Fernandez Gutierrez.
Panama were ahead on 18 minutes courtesy of a fine strike from Torres.
A fast counter-attack led to Marcos Sanchez playing the ball into the path of the Colorado Rapids forward, who side-footed a superb finish into the bottom corner.
A minute later and Panama could have doubled their lead in almost identical fashion.
This time it was Blas Perez on the end of the chance, but the FC Dallas striker's effort was too narrow and kept out by Brad Guzan.
Panama went close to doubling their advantage two minutes before half-time, but Perez was stretching and acrobatically volleyed Torres' cross over.
Julio Dely Valdes' men had a glorious chance to make it 2-0 just nine minutes into the second half.
Alberto Quintero's run down the left led to him cutting inside and setting up Perez, whose low side-footed shot was somehow kept out and scrambled away by the USA.
And Panama were made to pay for their wastefulness in the 64th minute as the USA equalised through Orozco.
Brad Davis' in-swinging corner bounced off Orozco and into the bottom corner to put Jurgen Klinsmann's men on level terms.
Soon after, Torres was denied after a lovely through ball by Quintero, with Guzan standing up to make a good save.
It was Guzan who was partly at fault for Panama's goal in the 83rd minute.
Substitute Roberto Chen was released down the right and composed himself and waited for runners before crossing.
Guzan parried the cross, but straight into the path of substitute Luis Tejada to tap in and send the home fans wild.
But Zusi headed in a Davis cross to break Panamanian hearts before Johannsson gave Klinsmann's men victory and left the hosts' players in despair after the final whistle.
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.