On a day when Spain was surprisingly knocked out of the World Cup by underdogs Russia, Croatia made sure it did not become another much-fancied team to falter -- but only just.
The largely disappointing Croatians had to rely on a penalty shootout to see off a Denmark side which was the better team in Niznhy Novgorod for long periods.
With the match tied at 1-1 after extra time, spot kicks were required for the second time in the day to decide a last-16 tie.
Croatian goalkeeper Danijel Subasic was his team's hero, saving penalties from Simon Kjaer, Lasse Schone and Nicolai Jorgensen to inflict a heartbreaking defeat on Denmark.
The loss was particularly harsh on Danish goalkeeper Kasper Schmeichel, who not only saved twice in the shootout but also denied Croatia captain Luka Modric from the spot in extra-time for what would likely have been the winner.
Modric went on to score in the shootout to help Croatia reach the quarterfinals for only the second time in its history, setting up a last-eight showdown with host Russia on July 8.
Croatia below its best
While Croatia would have the last laugh in this game, it was Denmark that drew first blood.
Mathias Jorgensen's stabbed effort from a long throw squirmed under Subasic's body with less than 60 seconds on the clock. Jorgensen's strike was the quickest goal of the tournament so far.
Within minutes, however, parity was restored thanks to some calamitous Denmark defending. The ball fell to Mario Mandzukic after bouncing off two defenders and the Croatian's swiveled strike leveled matters.
After such an exhilarating start the rest of the match plunged into a dull and uninspired affair until its stirring finale.
Much was expected of Croatia's all-star midfielders, Real Madrid's Modric and Barcelona's Ivan Rakitic, but the Croats were unable to dominate against well-organized opposition.
The Croats were one of three teams, along with Belgium and Uruguay, to win all three of their group games.
It's standout performance, of course, was the 3-0 thumping of Argentina. But the Croats were far below the standards set in that match.
Tottenham midfielder Christian Eriksen, as expected, pulled the strings for the Danes who looked especially dangerous at set pieces and were the better side after the break.
Yet it was only with extra-time minutes away that both offenses flickered into action with Rakitic going closest from distance.
When Jorgensen brought down Ante Rebic, conceding a 23rd-minute penalty in extra time, Croatia seemed on course for victory in 120 minutes.
But Schmeichel dived the right way to stop Modric and both teams were made to endure a nerve-shredding shootout.
Modric was fortunate it was a shootout his team would win.