Costa Rica scored in the 95th minute to salvage a 1-1 draw with Honduras and book their place at the 2018 World Cup.
Eddie Hernandez's 66th-minute header appeared set to put a wrench in the CONCACAF qualifying table, but Kendall Waston's late equaliser assured Costa Rica of their place in Russia next summer.
Costa Rica should have taken the lead on the hour mark when Honduras goalkeeper Donis Escober pushed the ball into the middle of the box with a diving save, but Marcos Urena somehow fired over the empty net from 12 yards.
And six minutes later Romell Quioto raced down the wing and crossed into the box, where Eddie Hernandez met the ball with a powerful header to put Honduras in front.
But deep into stoppage time, Waston headed in Bryan Ruiz's cross to set off massive celebrations in San Jose as Costa Rica qualified for their fifth World Cup and fourth of the last five.
The result pushes Costa Rica six points clear of Panama and Honduras with just one game remaining, ensuring Los Ticos will finish second behind Mexico in the final CONCACAF Hexagonal round.
The United States is in third place, the final automatic qualifying position, while Panama remained fourth, which would put them in the intercontinental playoffs against either Australia or Syria.
Panama and fifth-placed Honduras are both level on 10 points, but Panama have a superior goal difference despite their 4-0 defeat in the U.S. on Friday night.
Had Honduras held on, they would have moved into fourth, level on points with the U.S. But now they will have to better Panama's result on Tuesday night to finish fourth. Honduras host already-qualified Mexico on the final matchday, while Panama host Costa Rica.
Saturday's draw also means the U.S. will likely qualify with just a draw away to Trinidad and Tobago on Tuesday -- unless Panama or Honduras can make up a massive goal-difference deficit -- whereas a Honduras win in Costa Rica would have put pressure on the Americans to secure all three points.