Switzerland sailed into the pre-quarterfinals of the FIFA World Cup after playing out a thrilling 2-2 draw against Costa Rica in a Group E clash here on Wednesday.
Blerim Dzemaili (31st) gave Switzerland the lead before Kendall Waston restored parity for Costa Rica.
Josip Drmic (88th) helped the Swiss take back the lead but an own goal in second-half stoppage time by goalkeeper Yann Sommer (90+3) poured cold water on Swiss plans of a victory.
The result meant Switzerland finished second in the group behind Brazil with five points. Brazil won 2-0 against Serbia in another Group E match.
Costa Rica ended their preliminary round engagements rock-bottom of the group with just one point to show for.
The Costa Ricans, though, did not bow out without a fight. They created plenty of chances with great performances all over the pitch, but it wasn't enough in the end.
Dzemaili put the Swiss ahead, blasting home from the centre of the box after Breel Embolo headed a cross down into his path.
Costa Rica drew level after the break when Waston nodded in Joel Campbell's corner.
Drmic turned in a low cross from Denis Zakaria late into the second period and just when it looked like Switzerland were headed for a win, Zakaria conceded a penalty for a push on Campbell.
Bryan Ruiz sent his spot kick off the crossbar, but it ricocheted off Swiss keeper Sommer's back of the head and rolled over the line for an equalising own goal.
But Brazil's victory in the other game meant the Swiss would go through even if they lost.
They will now take on Group F winners Sweden in the round of 16.
The only blow for Switzerland was captain Stephan Lichtsteiner picking up two yellow cards meaning he will miss the knockout clash on Tuesday in St Petersburg.