The Canaleros looked well on their way to a victory that would have sealed a play-off against Oceania outfit New Zealand when Luis Tejada put the hosts 2-1 up with just seven minutes remaining.
However, Graham Zusi levelled matters in the second minute of injury time before Aron Johannsson struck in the dying seconds to snatch a dramatic win for USA that ended Panama's World Cup dream - but kept Mexico's alive in spite of El Tri's defeat to Costa Rica.
Panama came into the match knowing that anything but a victory would dash their hopes of a fourth-placed finish, and the home team responded by opening the scoring in the 18th minute, with Colorado Rapids Gabriel Torres hitting a hard and low shot past Braz Guzan in the American goal.
Panama nearly made it 2-0 10 minutes after half-time, but Aston Villa shot-stopper Guzan made a vital one-handed save.
With Costa Rica taking a second-half lead on Mexico, Panama's players were well aware that a win meant qualifying survival but their hopes were rocked when Brad Davis teed up Michael Orozco for an American equaliser in the 64th minute.
However, Panama City's Estadio Rommel Fernandez Gutierrez erupted when Tejada raced into the area to restore the home side's one-goal advantage. Unfortunately for the Canaleros, there was to be the most vicious sting in the tail.
Zusi rose majestically in the Panama area to head home a perfect cross from Davis to tie the game. The hosts were still coming to terms with that blow when Johannsson fired home a low strike from distance to silence a crowd that had been jumping just over a minute previously.