Goalkeeper Keylor Navas was the hero for 10-man Costa Rica as the nation reached the quarterfinals of the World Cup for the first time in their history after beating Greece 5-3 on penalties in Recife.
Bryan Ruiz's second-half goal was cancelled out in injury time by Sokratis Papastathopoulos, which sent the game to extra time and then penalties before Theofanis Gekas saw his spot kick saved and Michael Umana put away the winning penalty for Costa Rica.
Los Ticos have been the tournament's surprise package in Brazil, in overcoming Uruguay and Italy before holding England to a goalless draw as they won Group D.
That dream run continued Sunday in Recife, as they rode their luck against Greece to win a tense clash at the Arena Pernambuco to set up a quarterfinal clash against the Netherlands.
The Central Americans came into this match in the unusual role as favourites and looked to be wilting under the pressure, with only an exquisite stop by goalkeeper Keylor Navas stopping Dimitris Salpingidis from giving Greece a first-half lead.
Los Ticos were struggling to replicate the form they had shown in the group stage but managed to open the scoring with their first shot on target, as Bryan Ruiz directed home in the 52nd minute.
Costa Rica should have had a penalty soon after and were reduced to 10 men after 66 minutes, with Oscar Duarte's sending off eventually telling in stoppage time as Sokratis Papastathopoulos struck to take the match into extra time.
- Three points: Los Ticos beat back defensive-minded Greeks
- ESPN FC TV: Los Ticos to quarterfinals for first time
- Report: Costa Rica through on penalty kicks
- Video: Navas, Costa Rica deny Greece
There was to be no separating the sides in those 30 minutes, though, and after Greece coach Fernando Santos was sent to the stands, the match was decided on spot kicks.
It was an exciting end to a scrappy match in which the only moment of note in the opening 20 minutes was a left-footed drive from the recalled Cristian Bolanos that flew just over.
Greece were enjoying the lion's share of chances but were looking susceptible defensively at times, with skipper Giorgos Karagounis avoiding a penalty more through luck than judgement after catching Joel Campbell on the edge of the box.
It looked like a penalty on first glance, but referee Ben Williams was right to adjudge the foul to have taken place just outside the area, with the resulting free kick coming to nothing.
Veteran Karagounis tried his luck from distance when Greece returned to the attack -- a chance Navas dealt with easily, before having to be at his best to keep the scores level in the 37th minute.
Meeting a fine left-wing Jose Holebas cross, Salpingidis looked certain to score from close range, only for the Costa Rica goalkeeper to stop the goalbound strike with his right leg.
Duarte joined Andreas Samaris in the referee's notebook just before the halftime whistle went, with the locals letting their displeasure at the lack of quality known. Los Ticos failed to conjure a single shot on target in the opening period but changed that just seven minutes after the restart and broke the deadlock in the process.
Bolanos pulled the ball back from the left into the path of Ruiz, who was afforded too much time to coolly roll home a first-time left-footed strike, which trickled past Orestis Karnezis.
It was a fine placed effort, and Los Ticos should have had the chance to double their advantage moments later when Vasilis Torosidis turned away a cross with his hand.
Substitute Oscar Granado was booked for his remonstrations as tensions rose, with Costa Rica reduced to 10 men in the 66th minute when Duarte picked up a needless second booking for tripping Holebas.
Samaras flashed a header wide almost immediately before Navas flapped at his looped ball as Greece upped the ante.
Substitute Gekas turned wide, Kostas Manolas headed over and Karagounis wasted a free kick as the game looked to have got away from them, only for Papastathopoulos to net a stoppage time leveller.
With the ball fired into the box, Gekas saw a snapshot parried by Navas and the ball fell kindly for the centre-back to fire home. It was the first time the Costa Rica goalkeeper had been beaten from open play in Brazil, and he had to be at his best to stop Greece doing so again moments later in tipping over a powerful header from substitute Konstantinos Mitroglou.
The Fulham striker failed to get a telling touch to beat Navas again as extra time began, before an unsighted Gekas directed wide and Konstantinos Katsouranis had a close-range effort blocked.
Randall Brenes came close for Costa Rica at the start of the second period of extra time in which Lazaros Christodoulopoulos stung the palms of Navas, who then denied Mitroglou at the death as the match went to penalties.
Greece coach Santos was sent to the stands before the spot kicks began, with every one finding the net until Navas denied Gekas with Greece's fourth of the night.
It gave Umana the opportunity to secure victory, which he duly did by firing the ball into the top right-hand corner.