Danijel Subasic saved three penalties as Croatia knocked out dogged Denmark in a nerve-shredding shootout to set up a World Cup quarter-final tie against hosts Russia.
It came at the end of a largely disappointing tie - and one that had seen Luka Modric spurn a golden chance to snatch a late winner when his penalty shortly before the end of extra-time was superbly saved by Kasper Schmeichel.
The Leicester City goalkeeper also saved two penalties in the shootout at the Nizhny Novgorod Stadium but he could not prevent Ivan Rakitic slotting home the decisive 10th kick.
The Croatia players charged towards Rakitic after his decisive strike with the look of a team who knew they had survived an almighty scare against a Danish side that seemed to have the momentum with them moving into the shootout.
It was a match that ended in stunningly dramatic fashion - and started that way as well.
Martin Jorgensen capitalised on the chaos caused by a long throw to fire a weak shot beyond Subasic in the opening minute.
A scuffed clearance and an inadvertent header off Danish midfielder Martin Delaney left Mario Mandzukic with a good chance that he gobbled up, shooting beyond Schmeichel as Croatia soon levelled.
Neither side had previously conceded from open play in Russia - but the prospect of an unexpected glut of goals faded as quickly as the tempo.
It was a lacklustre tie played with front of a largely delighted crowd as the local fans inside the stadium revelled in Russia's earlier shootout victory over Spain.
The second half was particularly dreadful and the match seemed to have an inevitability of penalties from well before the start of extra-time.
An off-colour Modric fluffed his big chance but did convert in the shootout as Croatia stay alive in the competition and remain in the hunt to emulate the side of 1998, which reached the last four in France.
Croatia ride their luck
Croatia were superb the last time they played in Nizhny Novgorod, humbling Argentina 3-0 and laying down a real marker than they are contenders here in Russia.
But they were a shadow of that side on Sunday.
Their passing was off, they seemed to lack energy and ambition - and their ability to unpick a well-drilled opposition was limited.
Modric had warned before Sunday night's encounter that the Danes would provide a "stern test" and his words proved prophetic.
The Real Madrid man had come into this match on the back of several excellent displays but he and fellow influential midfielder Rakitic were well below par.
Modric's evening was perhaps summed up when he missed the chance to snatch a late win from the penalty spot.
In one of the few bright spots of his evening he had played an exquisite through ball to Ante Rebic, who seemed certain to score after adroitly rounding Schmeichel before he was brought down by goalscorer Jorgensen with the empty net gaping.
But Modric struck his kick at a good height for a keeper and Schmeichel, diving to this left, managed to hold the ball.
Croatia had been dumped out of Euro 2016 by Portugal in the last 16 after conceding late in extra-time and, as Denmark went into the shootout with their tails up, it did look as though they might suffer late heartbreak again.
But they survived - arguably fortunately - and remain alive in what is seen as the favourable half of the draw, with none of the teams left in Fifa's top 10 rankings.
Back in Euro 2016 Croatia missed out on winnable ties against Poland and Wales - and they do not want to do pass up a chance to go deep again.
Denmark so close to the class of 98
Denmark had only once previously reached the last eight of the World Cup - losing to Brazil at France 98 - but Age Hareide's side can consider themselves unfortunate to have lost against Croatia.
They sparked the game into life with their first-minute goal, which saw Huddersfield's Jorgensen shoot between the legs of two Croat defenders and defeat Subasic with what was a very saveable shot.
It came after a long throw from Ipswich's Jonas Knudsen and was very much made in the English Championship.
And they can hardly be blamed for playing to their strengths of defensive organisation and looking to capitalise on long throws and the occasional openings that come their way.
Christian Eriksen - who never lacked effort and endeavour but was a largely peripheral figure - clipped the apex of the goal in the first half and Denmark were undoubtedly the more ambitious side in an atrocious second half.
Denmark made a huge contribution to the worst game of the tournament so far when they and France played out a mutually convenient, insipid goalless draw in their final group match.
But they cannot be accused of spoiling this tie in Nizhny Novogorod, although in truth they probably exit the World Cup at a stage that is commensurate with their ability.
Man of the Match - Kasper Schmeichel
'The referee did not like us'
Croatia coach Zlatko Dalic: "It was a very difficult game. We conceded in the first minute, then we equalised. We missed a sitter. We miss penalties. We had chances but we stayed strong, mentally composed, and we won eventually."
Denmark goalkeeper Kasper Schmeichel: "It's a strange feeling. Huge disappointment. But also enormous pride about our team.
"I think today we had the opportunity. I think we were the better team in the second half and the extra-time.
"I don't think we had any luck. I don't think the referee liked us today. It is difficult to accept and put into words. There are many emotions right now."
Quick off the mark - the stats
■ Croatia have qualified for their first World Cup quarter-final since 1998.
■ Denmark have lost two of their three penalty shootouts at major tournaments, also losing against Spain in the Euro 1984 semi-final (they won the other at Euro 1992 against Netherlands).
■ This match was only the second in World Cup history to see both teams score inside four minutes, after Argentina v Nigeria in June 2014.
■ Mathias Jorgensen scored for Denmark after 57 seconds, the fastest goal scored in a World Cup match since Clint Dempsey scored after 29 seconds for USA against Ghana in 2014.
■ Mario Mandzukic's equaliser for Croatia after three minutes and 40 seconds was Croatia's second fastest World Cup goal, behind only Darijo Srna's strike against Australia in June 2006 (1:56).
■ Since 1966, only one penalty has been taken later in a World Cup match than Luka Modric's penalty for Croatia (115mins 46secs) - Asamoah Gyan for Ghana against Uruguay in 2010 (121:27), whose penalty hit the crossbar.
■ Mandzukic scored his third World Cup goal for Croatia (also two goals in 2014), with only Davor Suker (6) scoring more for the Croatians.
■ Both Croatia and Denmark played their 20th World Cup games in this match, with this the first time for each nation that any of those 20 games has gone to extra-time.
■ Denmark have conceded three penalties at the 2018 World Cup, the most by a team in a World Cup since Greece in 1994 (also three conceded).
■ Today is only the second day in which two World Cup games (Spain v Russia, Croatia v Denmark) both went to a penalty shootout - the other was June 21, 1986 (France v Brazil, Mexico v Germany).
BBC