Costa Rica are into the quarter-finals of the World Cup for the first time in their history after beating Greece 5-3 in a penalty shootout in Recife.
Sokratis Papastathopoulos’s injury-time equaliser for Greece had cancelled out Bryan Ruiz’s side-footed opener and sent the game into extra time.
Costa Rica, down to 10 men for almost an hour after Oscar Duarte’s dismissal, scored their first four spot-kicks.
Theofanis Gekas missed for Greece, and Michael Umana settled the tie.
It means the Central American side – surprise qualifiers from a group containing England, Italy and Uruguay – go through to face the Netherlands on Saturday for a place in the semi-finals as their unlikely run at the World Cup continues.
The last-ditch equaliser and the penalty shootout added belated drama to what had been a less than enthralling encounter at times.
Dimitris Salpingidis had the best chance of a turgid first half but his close-range volley from a fine Jose Holebas cross was saved by the legs of Costa Rica’s Keylor Navas – the first of several crucial interventions by the Levante keeper.
Christian Bolanos had already sent a half-chance over the bar for Costa Rica while Greece’s Giorgos Karagounis saw a long-range effort comfortably saved as erratic passing meant chances were a rarity.
Greece started the second half well with Giorgos Samaras heading a Holebas cross straight at Navas from six yards.
But it was Costa Rica who broke the deadlock with their first shot on target.
Fulham forward Ruiz, who spent the latter part of last season on loan at PSV Eindhoven, converted from the edge of the area, placing a precise side-foot into the corner of the goal after a Bolanos pass from the left found him in space.
The Central Americans were incensed not to be given the chance to double their lead after Greek defender Vasilis Torosidis appeared to handle in the box and then lost Duarte when he brought down Holebas to pick up a second yellow card.
Although the game opened up as a result of the dismissal, neither side was able to create a clear opening until the final minute of the game when Papastathopoulos found the net with a scuffed shot from inside the box after Navas had parried Gekas’s shot into his path.
The goal, Papastathopoulos’s first in international football, sparked wild celebrations on the Greek bench and they might even have won it in what remained of normal time but Navas superbly tipped Kostas Mitroglou’s bullet header over the bar.
Greece had further half-chances through Gekas and Kostas Katsouranis before a golden opportunity to win it arrived in the second half of extra time.
They broke upfield from a Costa Rica corner and found themselves with a 5-2 advantage, the ball eventually finding its way to Lazaros Christodoulopoulos – but once again Navas responded agilely to turn the strike away for a corner.
And Costa Rica had their keeper to thank yet again as he saved Mitroglou’s late half-volley from six yards in the last seconds of extra time.
There was to be further drama before the penalties had even begun as Greece manager Fernando Santos was sent off.
The first seven spot-kicks were confidently dispatched before Navas made his final and decisive contribution, saving from Gekas and leaving Umana to put Costa Rica through.