Switzerland booked themselves a second round date with Sweden in Saint Petersburg as they drew with Costa Rica, whose goals mean that every team at the 2018 World Cup has scored at least once.
Switzerland made two attacking changes, bringing in Breel Embolo and Mario Gavranovic. Costa Rica, already eliminated, made three alterations: Joel Campbell, Kendall Waston and Daniel Colindres all came into the side.
Costa Rica started the brighter of the two teams and had an early penalty appeal for a Ricardo Rodriguez handball turned away. Yann Sommer made two excellent saves in quick succession to palm away a Joel Campbell strike and then to push a Celso Borges header onto the post.
Colindres beat Sommer with a superb dipping effort but was denied by the crossbar as Los Ticos' good start continued. But Switzerland's first shot on target resulted in the first goal as Xherdan Shaqiri's cross was headed down by Embolo and lashed in by Blerim Dzemaili.
Switzerland were briefly top of the group before Paulinho put Brazil ahead in Moscow, and that was how it stayed until half time.
Costa Rica started the second half as they had started the first but Campbell spurned a good chance in the box as he sliced the ball wide. Embolo tested Keylor Navas with Switzerland's first chance of the half, though in truth the angle was too narrow to score from.
Los Ticos got the goal they deserved, but it was far too easy. Campbell floated in a corner and Waston rose to glance it past Sommer, who was left exposed by the poor marking of his defence.
With Thiago Silva extending Brazil's lead against Serbia, Switzerland knew that they were in no danger of elimination even if Costa Rica scored another, which they looked like they might as Sommer flapped at another corner, but there was nobody there to convert on this occasion.
Substitute Josip Drmic came close to restoring Switzerland's lead with a header that struck the angle of post and crossbar, before a superb individual run from Campbell put Switzerland in trouble and Sommer bailed them out again.
The game appeared to be petering out but there was still time for a crazy final few minutes. A low cross was drilled in from the right and Drmic raced onto it to fire a low effort past the stationary Navas.
The Central Americans thought they had a chance to salvage a point when the referee pointed to the spot after Bryan Ruiz tumbled in the box, but a VAR review revealed that the fouled player was offside and the decision was reversed.
But then they did get a penalty. Campbell got in behind the Swiss defence and got his legs in a tangle with two defenders. Ruiz stepped up to score his 25th international goal, but he struck the woodwork and it bounced into the net off Sommer.
It was a disappointing end for Switzerland, but they still go onto the last 16 in 2nd place. They will play Sweden in Saint Petersburg next Tuesday.