Switzerland have reached the knockout stages of the 2018 World Cup thanks to a 2-2 draw with Costa Rica in Wednesday's Group E match at the Nizhny Novgorod Arena.
Blerim Dzemaili opened the scoring just after the half-hour mark with a thumping close-range drive, only for Kendall Waston to level on 56 minutes with a deft header from a corner.
The Swiss then surged ahead with just two minutes left through Josip Drmic, but Costa Rica were handed an injury-time penalty, just minutes after another spot kick was disallowed by VAR.
Bryan Ruiz, likely to be playing his final game for Los Ticos, stepped up to the spot, and his effort ricocheted off the woodwork and off Yann Sommer's body for an own goal in an entertaining end to the game.
Switzerland coach Vladimir Petkovic made just two alterations from the 2-1 win over Serbia, with Breel Embolo and Mario Gavranovic brought into the side in place of Steven Zuber and Haris Seferovic.
Crucially, the trio of Stephan Lichtsteiner, Granit Xhaka and Xherdan Shaqiri were able to start after their 'double-headed eagle' celebrations against Serbia were sanctioned with fines rather than suspensions.
Though the Swiss had more at stake, with progress to the last 16 still a possibility, the already-eliminated Costa Ricans were quick out of the starting blocks in a frantic start that saw Sommer pull off a number of superb saves.
In addition, Ricardo Rodriguez was let off despite a Joel Campbell cross brushing his outstretched hand in the box, while Daniel Colindres saw an effort come off the underside of the bar as the Swiss were made to sweat in the early stages.
The pendulum swung the other way on 31 minutes when Lichtsteiner's cross from the right, was flicked into the path of Dzemaili by Embolo, taking out much of the Costa Rica backline, and the Bologna man hammered home on the volley to put Switzerland ahead and briefly top of the group.
Though Brazil soon took the lead against Serbia in Moscow to nudge the Swiss back into second, the momentum was firmly with Petkovic's charges, who got to the break without too much difficulty as their opponents lost some of their prior composure.
Costa Rica, who remained the only team at the World Cup not to have scored, eventually got off the mark just before the hour as Waston rose highest to meet Campbell's outswinging corner, flicking a header past Sommer and into the corner of the net from six yards.
The game soon lost a lot of its energy, with Switzerland seemingly seeking to shut up shop as news filtered through of Brazil doubling their lead against Serbia, but there was yet time for late drama.
Moments after crashing a header against the post, substitute Drmic slotted into the bottom corner from Denis Zakaria's low cross for what looked like the winning goal for Switzerland.
Costa Rica were then given a penalty, only for an offside to rule the spot kick out, but a minute later came another penalty decision, which saw Ruiz get the ball into the back of the net via the woodwork and Sommer for a share of the points.
The result means that Switzerland take second place in Group E and will take on Group F winners Sweden in St Petersburg on Tuesday, July 3.
SWITZERLAND (4-2-3-1): Sommer; Lichtsteiner; Schar, Akanji, Rodriguez; Behrami (Zakaria 60'), Xhaka; Shaqiri (Lang 81'), Dzemaili, Embolo; Gavranovic (Drmic 69')
COSTA RICA (3-4-2-1): Navas; Acosta, Gonzalez, Waston; Gamboa (Smith 90+3'), Borges, Guzman (Azofeifa 90+1'), Oviedo; Colindres (Wallace 81'), Ruiz; Campbell