Switzerland booked their spot in the last 16 of the World Cup courtesy of a 2-2 draw with Costa Rica in Nizhny Novgorod on Wednesday.
Brazil's win over Serbia in the night's other Group E game means that Vladimir Petkovic's side finish second in the pool and will take on Sweden in St Petersburg on Tuesday.
Switzerland – whose last-gasp win over Serbia in their second game set them up for progression to the knockout stages – were second best for large periods against their already eliminated opponents, but did take the lead just after the half-hour mark.
Blerim Dzemaili took advantage of generous marking to power home from close range before Kendall Waston pulled Costa Rica level shortly after the interval.
Substitute Josip Drmic thought he had secured all three points for Switzerland with a cool 88th-minute finish before Bryan Ruiz's penalty cannoned off Yann Sommer for an unfortunate own goal to ensure a share of the spoils.
Switzerland's attentions now turn to their crunch clash with Janne Andersson's side, while Costa Rica are left to reflect on a campaign that fell well short of their magical run to the quarter-finals in 2014.
Costa Rica started with a freedom that was missing from their first two games, carving out a number of excellent opportunities in the early stages.
Sommer did well to palm away Joel Campbell's fierce drive from distance after six minutes and then produced an outstanding save low down to his right to tip Celso Borges' powerful header onto the post.
The Central Americans' early swagger showed no signs of abating and they came agonisingly close to an opener after 10 minutes, Daniel Colindres' curling effort from 25 yards crashing against the crossbar with Sommer well beaten.
Switzerland's over-worked goalkeeper was called into action again midway through the first-half, getting down smartly to push Bryan Oviedo's drilled strike around the post.
Petkovic's men had scarcely posed an attacking threat during the first half, but took an undeserved lead with their first sight of goal after 31 minutes.
6 - Switzerland have now scored at least once in 6 of their last 7 World Cup games - as many as their previous 15 combined. Sharp. #SUI #CRC #SUICRC #WorldCup pic.twitter.com/ya6Vme6jx0 — OptaJoe (@OptaJoe) June 27, 2018
Stephan Lichsteiner's right-wing cross was headed back across goal by Breel Embolo, and the unmarked Dzemaili lashed home from eight yards.
Ricardo Rodriguez almost scored a stunning second just after the interval, but his half-volley from outside the area fizzed just over Keylor Navas' crossbar.
Navas was called into action shortly after, blocking Embolo's acute effort at his near post, before Waston deservedly pulled Costa Rica level after 56 minutes.
The defender rose highest to meet Campbell's outswinging corner, flashing a header past Sommer from six yards to register his side's first goal of Russia 2018.
Moments after crashing a header against the post, Drmic slotted into the bottom corner from Denis Zakaria's low cross for what looked like the winning goal.
There was late penalty drama, though, as VAR once again proved decisive.
Referee Clement Turpin awarded a spot-kick after Ruiz had been bundled over in the area, only for the decision to be reversed after replays showed the Costa Rica captain had strayed into an offside position when he received the ball.
Ruiz did get a chance from the spot in the third minute of stoppage time when Campbell was felled in the box, his penalty thumping back off the crossbar and against Sommer's head to complete a frantic finale.