Mexico have escaped with a spot in a two-legged play-off to qualify for Brazil 2014, despite losing 2-1 to Costa Rica on Tuesday.
Manuel Vucetich's Mexico side looked set to miss their first World Cup finals in 24 years as Panama, their rivals for the intercontinental play-off berth against New Zealand, took a crucial lead over the United States.
But Mexico's arch-rivals, the USA, did them a favour, scoring twice in second-half injury-time to stun Panama 3-2 and ensure the loss in Costa Rica did not matter for Vucetich's team.
The results on the final matchday of CONCACAF's fourth round of World Cup qualifying saw Mexico finish with 11 points in fourth position, three clear of Panama, who would have earned the play-off berth on goals scored if they had defeated the USA.
The match at the Estadio Nacional de Costa Rica began in scrappy fashion with neither team fashioning a genuine chance on goal in the opening quarter of an hour.
But Mexico were in danger of missing out on the World Cup for the first time since 1990 and that knowledge seemed to spark the visitors, who were denied a goal in unusual circumstances after 17 minutes.
A great move through midfield saw Carlos Pena slide a pass to Oribe Peralta on the right side of the box and the striker squared the ball to Javier Hernandez, who scuffed his shot towards goal.
With Costa Rica's goalkeeper Keilor Navas stranded, Hernandez's effort rolled slowly towards the goal-line but Peralta, who was offside, looked set to slam the ball into the net before thinking better of it, letting it through his legs to nestle in the corner of the net.
Despite Peralta having not touched the ball, the referee whistled for offside.
The visitors were denied again soon after with Pena's shot blocked by a diving Costa Rica defender, before the hosts dealt Mexico a blow in the 25th minute when Bryan Ruiz slammed home the opening goal after spinning away from two defenders.
With Panama taking the lead over the USA in the other crucial CONCACAF qualifier, Mexico were in trouble but equalised quickly when Peralta thumped a loose ball into the net off the underside of the crossbar after Navas had denied Hernandez.
Mexico dominated the rest of the half but failed to convert and that lack of cutting edge came back to haunt them in the 65th minute when Cristian Gamboa's cross found Alvaro Saborio unmarked in the penalty area and the Real Salt Lake striker made no mistake with his header.
Almost immediately, Costa Rica goalkeeper Guillermo Ochoa palmed away Raul Jimenez's header as Mexico searched for another equaliser, although they seemed safe as the USA equalised in Panama.
Costa Rica then hit the post as Cristian Bolanos played a one-two with Saborio but could only dink his shot onto the woodwork and the ball bounced out.
With around seven minutes remaining, Panama moved 2-1 ahead of USA but Mexico failed to respond and were on the verge of elimination until two late goals by the Americans ensured Vucetich's team will play New Zealand in a two-legged play-off in November.
Meanwhile, Honduras confirmed their place at Brazil 2014 despite playing out a disappointing 2-2 draw at last-placed and winless Jamaica.
|Coach: J. Pinto|
for B. Ruiz 49'
for Y. Tejeda 72'
for J. Campbell 77'
|Age is just a number - Ilori defends Klopp´s team selection|
|Messi, Suarez and Neymar rested for Copa second leg|
|Madrid can dream of trophies under Zidane - Raul|
|Ancelotti: Italy job is a decade away|
|Reus will become a monster, says Dortmund boss Tuchel|
|Young Tottenham stars don´t know their limits - Lloris|
|Niang happy at Milan despite Leicester interest|
|Ticket price rise means more tourist fans, warns football supporters chairman|
|Ogbonna revels in first West Ham goal|
|Copa Libertadores Review: Huracan, River Plate advance to group stages|
|Klopp backs Benteke to rediscover goalscoring form|
|Turan will not leave Barca for China - agent|
|Beating Chelsea more difficult without Mourinho - Motta|
|Tuchel praises Dortmund for ´perfect game´|
|Klopp rues Liverpool wastefulness in FA Cup loss|
|Allegri: Chelsea rumours unfounded|
|Bilic feels weight of history after Liverpool win|
|Coupe de France Review: Second tier Sochaux stun Ligue 1 Monaco|
|West Ham 2 Liverpool 1 (aet): Ogbonna sinks Klopp´s men in cup thriller|
|Football League Review: Rhodes rescues a point to send Boro top|
|Stuttgart 1 Borussia Dortmund 3: Aubameyang helps Tuchel´s men into last four|
|Kyle Allen blames chaotic Texas A&M culture on Johnny Manziel era|
|Dortmund fans stage protest against ticket prices for Stuttgart game|
|Bayer Leverkusen 1 Werder Bremen 3: 10-man hosts dumped out|
|Ferdinand fears title wilderness for United|
|Carvalho lands new Sporting deal with €45m buy-out clause|
|Ben Arfa out for at least four weeks with hamstring injury|
|Neville´s Valencia woes welcomed by Crespo|
|Ozil key to Arsenal´s title hopes - Rosicky|
|Zika threat could keep Solo from Rio Olympics|
|Blanc pleased to have solved David Luiz matter|
|Atletico midfielder Partey suffers thigh strain|
|Dickov: Leicester title run built to last|
|Guardiola not a menace for our players, says Luis Enrique|
|Mexico v Senegal: Osorio believes in youngsters|
|Celta Vigo v Sevilla: Krohn-Dehli not taking Copa del Rey final for granted|
|Madrid confirm Marcelo shoulder dislocation|
|Injury rules Chiellini out of crucial Juve games|
|Oblak extends Atletico deal|
|Blanc hints PSG could move for Ben Arfa|
|Luis Enrique urges Neymar to cope with off-field distractions|
|Carrick: Manchester United not throwing in towel|
|Neville determined to turn things around at Valencia|
|Guardiola hails Lewandowski professionalism amid Real Madrid and PSG rumours|
|Guardiola wary of ´aggressive´ Bochum|
|Premier League reveals new logo|
|West Ham open Payet contract talks|
|I could leave Barcelona for Guardiola, says Busquets|
|Giggs can be Manchester United´s Guardiola - Robson|
|Zidane has everything to become a great coach - Ancelotti|
|Carragher: Liverpool got it wrong on ticket prices|
|Neymar will be at Barcelona for years, claims director|
|Eder talks up Inter´s Scudetto chances|
|Larsson: Watching Barca is like playing FIFA|
|City recruit Wilkinson hoping to debut in Melbourne derby|
|Allegri will join Chelsea, says former coach|
|Zanetti: No need to compare Maradona and Messi|
|Vardy: I never expected Leicester to top Premier League|
|Capello: Ronaldo has at least three years at the top|
|Klopp hoping for Sturridge revival|
|Bilic wants new contract to keep Payet at West Ham|
|Shelvey can be as good as Cabaye - Sissoko|
|Rooney leaps to Depay defence after Chelsea error|
|Januzaj, Varela injured in United Under-21s win|
|Valencia v Barcelona: Luis Enrique eyes record as Neville stands on the brink|
|Espanyol 0 Real Sociedad 5: Vela scores stunner in ruthless display|
|Cruyff would have preferred Guardiola at Manchester United|
|Questioning Ronaldo is an insult - Aduriz|
|Peterborough United v West Brom: Berahino set for another chance|
|Barcelona confirm medical tests for Messi|
|Ajax defender Riedewald out for season with broken ankle|
|Barcelona is the best place for Neymar - Mascherano|
|Clement axed as Derby head coach|
|Chelsea defender Zouma out for the season|
|Rodgers: I´ve turned down Swansea and four other clubs since Liverpool|
|Russia to invite Blatter and Platini to World Cup 2018|
|Robben rejoices as Ribery resumes Bayern training|
|Terry as good as ever, says Azpilicueta|
|Struggling Rotherham sack Redfearn|
|Courtois feels Champions League or FA Cup glory would save Chelsea´s season|
|Paris Saint-Germain v Lyon: Genesio vows ´unlucky´ visitors will have a go|
|Liverpool cancel Q&A to discuss ticket price furore|
|Klopp: Liverpool won´t follow Payet to the toilet|
|Bochum v Bayern Munich: Alonso braced for intense month|
|Ronaldo: Two more years at Real Madrid and then we´ll see|
|No problems with Kagawa says Dortmund boss Tuchel|
|Laporte denies saying he would reject Barcelona|
|Impressive Sturridge and returning Coutinho in contention - Klopp|
|Leicester were afraid of Italian tactics - Ranieri reveals his secret|
|Coentrao sustains fractured foot|
|Barcelona director at ease over Neymar future|
|Mata touched by reaction of Chelsea fans|
|Alonso: Guardiola departure not a distraction|
|Thiago Silva: PSG can stay unbeaten all season|
|Cristiano Ronaldo will keep breaking records - Hugo Sanchez|
|Bilic: Klopp will be back because he is a leader|
|Mancini dismisses Inter title bid as ´a closed story´|
|Guardiola took Bayern for a ride - Hamann|
|Mihajlovic demands more from Balotelli|
|Campbell urges clubs to give black managers a chance|
|Marchisio expects Napoli showdown to be decisive|
|You can´t expect to score lots of goals in every game - Modric|
|FFA hit Wanderers with show cause notice|
|We did not deserve Madrid defeat - Granada coach|
|Mata frustrated with Chelsea draw|
|Valencia won´t sack Neville - Mendieta|
|Senna makes Villarreal return|
|Spalletti: Roma need to cut out lapses|
|China will break $100m transfer fee - Cahill|
|Ranieri: Don´t look down|
|Guardiola reinvented football - Alaba|
|Tottenham fear no one - Kane|
|Flores believes Tottenham are Premier League´s best|
|Henderson: Walkout no excuse for Sunderland collapse|
|Neville bullish about Valencia future|
|Ramos: Modric key for Madrid|
|La Liga Review: Luis Enrique matches Guardiola record, Modric rescues Madrid|