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'
|Ronaldo omitted from Portugal squad|
|Academica 1 Vitoria Setubal 1: Paulo Sergio´s men still waiting for first win|
|Marseille 4 Nice 0: Payet helps secure first home win for Bielsa|
|Go Ahead Eagles 1 Willem II 0: Vriends on target as hosts clinch win|
|Augsburg 2 Borussia Dortmund 3: Ramos strike proves crucial for visitors|
|McCarthy completes QPR switch|
|Paris Saint-Germain v Saint-Etienne: Injury-hit champions set for stern test|
|Tottenham v Liverpool: Rodgers downplays Balotelli arrival|
|Montpellier and Spurs agree Stambouli fee|
|Torres set for two-year Milan loan|
|Real Sociedad v Real Madrid: Ancelotti´s men on the road after departures|
|Bamford loaned to Middlesbrough|
|Gallifuoco makes Swansea move|
|Aston Villa v Hull City: Visitors seek Europa League hangover cure|
|Douglas completes Barca switch|
|Van Gaal hits out at Hodgson over Shaw|
|Villarreal v Barcelona: Rakitic grounded after promising start|
|Lallana poised for Liverpool debut|
|Mourinho bullish on Torres future|
|Clasie signs Feyenoord extension|
|Allegri raring to go|
|Two changes to Netherlands squad|
|Milan v Lazio: Inzaghi and Pioli reigns get under way|
|Costa still in contention for Everton|
|Squad size crucial for marathon season - Garcia|
|Leicester City v Arsenal: Wenger predicts tough challenge|
|Pellegrini hopes CSKA have learned lessons|
|Ibe opts for Derby switch|
|New faces in Spain squad|
|Holders Sevilla handed difficult Europa League draw|
|Egypt v Kenya: Williams era begins in Aswan|
|Pardew: Newcastle move key to Colback call-up|
|Van Gaal had not expected Rojo delay|
|Alonso: Kroos arrival not a factor|
|McGregor commits to Celtic|
|McGregor commits to Celtic|
|Low picks 18 World Cup winners for final rematch|
|Wenger coy over new signings|
|Redknapp ready to sign new QPR deal|
|Palace hand Bolasie new deal, table Traore bid|
|Alonso finalises move to Bayern Munich|
|Qualification a ´big step´ for Saint-Etienne|
|Thohir coy on Lavezzi talk|
|Faurlin injury curse strikes again|
|PSG president confident after Champions League draw|
|Hull closing on Hernandez deal|
|Warnock held Palace talks last year|
|Slomka cools Holtby talk|
|Slomka cools Holtby talk|
|Marotta confident of Juventus success|
|Marotta confident of Juventus success|
|Aguirre: New era for Japanese football|
|CONCACAF Champions League Review: Olimpia go top|
|Torino v Inter: Visitors out to maintain dominance|
|Copa Sudamericana Review: Penarol cruise into second round, Cesar Vallejo do it tough|
|Costa Rican Primera Division Review: Uruguay remain winless|
|Ronaldo backs Di Maria to shine at United|
|Argentine Primera Division Review: Velez stay perfect, Sanchez inspires River|
|Copa do Brasil Review: Cruzeiro win big, Corinthians lose|
|Barca wary of ´difficult´ opponents|
|Ronaldo confident after Champions League draw|
|´Not an easy´ draw for Dortmund|
|Bruce laments ´worst´ elimination|
|UEFA Europa League Play-Off Review: Lyon and Sociedad dumped out, Inter win big|
|Robinson joins QPR|
|Mazzarri lauds Kovacic development|
|Townsend eager to get back to full fitness|
|Tottenham 3 AEL 0 (agg 5-1): Spurs cruise into Europa League proper|
|Leicester complete sensational Cambiasso swoop|
|Del Piero confirms move to Indian Super League|
|Hull City 2 Lokeren 1 (agg 2-2): Lokeren progress despite Brady brace|
|Benatia excited to face Roma|
|Inter 6 Stjarnan 0 (agg 9-0): Kovacic treble sees hosts cruise through|
|Championship Preview: Redfearn in charge for Bolton clash, Magath eyes first league win|
|Newcastle United v Crystal Palace: Warnock kicks off second Palace stint|
|Atletico Madrid v Eibar: Champions seek first win|
|Rodgers excited about ´special´ draw|
|Manchester City v Stoke City: Pellegrini could chop and change|
|Warnock has no issues with Puncheon|
|Sacked Hockaday´s tenure at Leeds lasts just six games|
|Palace re-sign Zaha on loan|
|Burnley v Manchester United: Van Gaal hoping to kickstart recovery|
|Ronaldo named Europe´s best|
|Swansea City v West Brom: Monk wants Liberty fortress|
|Cameroon confident DR Congo clash will go ahead|
|West Ham v Southampton: Koeman anticipating physical West Ham challenge|
|Hughes expecting tough City test|
|Holders Real set for Liverpool test|
|Monk targeting two more additions|
|Koeman keen for ´difficult´ transfer window to end|
|Van Basten absent due to health issues|
|League Two Preview: Morecambe chase another win, giant-killers back in action|
|Irvine eyeing another winger|
|Van Gaal confirms more signings to come|
|Barca are constantly improving, says Rakitic|
|Di Maria is not ´the miracle´, says Van Gaal|
|Torres Milan move ´a real possibility´|
|Juventus v Chievo: Allegri begins quest to replicate Conte success|
|League One Preview: MK Dons and Orient aim to follow up historic wins|
|Schalke v Bayern Munich: Benatia in line for debut|
|Pirlo blow for Juve|
|Napoli defender Ghoulam suffers fractured arm|
|QPR v Sunderland: Redknapp desperate for points|
|Everton v Chelsea: Costa absence could prove costly|
|Deschamps makes two changes to France squad|
|Warnock excited by Palace challenge|
|Lambert: Delph deserves England call-up|
|Aguirre names five uncapped players in Japan squad|
|Ki signs new four-year Swansea deal|
|CSL Preview: Lippi returns to dugout, Beijing Guoan host rock-bottom Harbin Yiteng|
|J.League Preview: Yoshida out to keep pressure on Urawa|
|Chambers, Delph, Colback win England call-ups|
|Rooney named new England captain|
|Costa in doubt for Everton trip|
|Ross County sack Adams|
|Platini wants more UEFA representatives at World Cup|
|Allardyce hints at big-name signing|
|Platini will not challenge Blatter for FIFA presidency|
|Bruce convinced of qualification|
|Alonso set to swap Madrid for Munich|
|Pochettino to use MK Dons as an example|
|Champions League difficult for Arsenal - Bilic|
|Redknapp takes aim at ´really poor´ QPR|
|MLS Preview: Timbers braced for ´massive´ clash in Vancouver|
|Los Angeles Galaxy 4 DC United 1: Arena´s side show quality|
|Copa Sudamericana Review: River Plate, Libertad among teams to progress|
|CONCACAF Champions League Review: Pachuca in seventh heaven, Leon held|
|LDU Quito 3 Deportivo Quito 0: Hosts earn bragging rights against rivals|
|Johnson calm over future|
|Kiessling hails Leverkusen|
|Benitez: Mistakes cost Napoli Champions League spot|
|K. League Preview: Seoul eyeing winning streak|
|Liga MX Preview: Monterrey looking to build momentum|
|Valverde hails ´historic day´ for Bilbao|
|UEFA Champions League Review: Mixed results for Europe´s big guns, Moti the hero for Ludogorets|