Needing only a point to qualify, Honduras made sure of their place by drawing 2-2 with Jamaica in Kingston to join the US and Costa Rica as the three automatic qualifiers from the CONCACAF region after a dramatic final round of matches.
Regional heavyweights Mexico were minutes away from missing out on the fourth-placed play-off spot when they were beaten 2-1 in Costa Rica and Panama held a 2-1 lead over the Americans.
But Panama, who needed to win to leapfrog Mexico in the six-nation qualifying tournament, conceded two goals in stoppage time to lose 3-2, prompting shock, disbelief and jubilation among Mexican fans.
"Play-off courtesy of the gringos," former Mexican President Felipe Calderon tweeted. "What happened?"
In parts of Mexico City, bands played in celebration and car drivers honked their horns, while men sat outside in the street, drinking beers and discussing the last ditch escape.
Shopkeeper Marcelo Rodriguez, 40, was downcast.
"We need committed players, and we don't have any," he said.
"You can't rely on your old enemy to save you."
Mexico now face Oceania winners New Zealand in a two-leg play-off in November in an effort to continue their long streak of World Cup appearances while Honduras will make their third appearance at the game's showpiece event.
Honduras made the perfect start against Jamaica when Carlo Costly scored in the first minute but the home side, who failed to win a match in the final round, drew level two minutes later through Je-Vaughn Watson.
Honduras regained the lead after 33 minutes to go into the break with a 2-1 advantage when Maynor Figeuroa scored off a free kick but Jamaica equalised in the second half when Rodolph Austin converted a penalty.
Honduras survived some anxious moments but their defence held firm before the players celebrated booking their passage to Brazil.
The win also triggered celebrations in the Honduran capital, Tegucigalpa, where thousands of people poured into the streets waving national flags and soccer strips as fireworks lit up the night sky.
"All us Hondurans are happy, we've qualified for the World Cup. When we unite, we win," President Porfirio Lobo told local radio, saying he would declare Wednesday a holiday for government employees so they can celebrate.
Mexico have qualified for every World Cup since 1982, with the exception of 1990 when they were banned by FIFA after fielding over-age players in a youth tournament, have the chance to qualify after an extraordinary final week.
Last Friday, they needed a stunning goal from Raul Jimenez five minutes from fulltime to beat Panama at home then on Tuesday needed the help of the US to keep ahead of Panama.
Mexico fell behind early against Costa Rica when striker Brian Ruiz scored for the home team in the 26th minute.
Although Mexico equalised three minutes later through Oribe Peralta, whose shot hit the underside of the bar, Costa Rica went back in front when Alvaro Saborio headed what proved to be the matchwinner in the 64th minute.
Mexico's hopes of staying alive rested on the result of Panama's match with an understrength US side, who had the luxury of resting some of their regular starters after already finishing top of the group standings.
Panama, who have never qualified for the World Cup, led 1-0 at the break after Gabriel Torres found the back of the net in the 18th minute.
Michael Orozco brought the Americans back on level terms in the 64th minute but Panama regained control when Luis Tejada scored seven minutes before full-time, tapping in a rebound.
The goal set off wild celebrations in the Rommel Fernandez Stadium but the cheers turned to disbelief when a header from Graham Zusi then a long range strike from Aron Johannsson in injury time ended their World Cup hopes.