The Barcelona midfielder's winner came after Milan Badelj and Josip Pivaric saw their penalties saved by Danish goalkeeper Kasper Schmeichel, who also saved an extra time penalty from Luka Modric.
But Danes Christian Eriksen, Lasse Schone and Nicolai Jørgensen were thwarted by Croatian goalkeeper Danijel Subasic in the shootout to ensure Croatia won 3-2 and advanced to their first quarter-finals since the 1998 World Cup in France.
The dramatic ending followed early excitement -- but little in between. In an astonishing start to the match, both teams scored within four minutes via their first attacks.
First, Mathias Jørgensen turned home in the second minute after Croatia failed to clear a long throw-in from Jonas Knudsen, the defender's shot creeping under Subasic to give Denmark the perfect start.
But any hopes they could hold onto their lead vanished within 90 seconds. With the Nizhny Novgorod stadium still rocking from the frantic start, Croatia went upfield and promptly equalised.
Again, the goal owed more than a little to bad defending when a Sime Vrsaljko cross was hammered by Henrik Dalsgaard into fellow Dane Andreas Christensen and the ball fell obligingly in the penalty area to Mario Mandzukic who scored.
The explosive start -- both sides hit the back of the net within three minutes and thirty-seven seconds -- was officially the quickest two teams have ever scored in a World Cup finals match.
The following 116 minutes though largely failed to live up to the first four, fireworks giving way to a damp squib of an encounter as the game edged inexorably towards extra time and penalties.
Billed as a clash between the opposing number 10s, Modric and Eriksen, it instead became increasingly attritional and tactical, with both playmakers unable to find any space.
Instead the player who created most chances was Knudsen with his long throws.
Few clear chances were created by either side until Modric's late penalty miss. That came after Ante Rebic was fouled in the 116th minute Mathias Jørgensen, with the goal at his mercy.
Modric stepped up but side-footed weakly and Schmeichel made the first of his three penalty saves on the night, all in vain, as his legendary goalkeeping father Peter punched the air in delight as he watched on in the stands.