Giorgios Samaras converted a penalty against Ivory Coast three minutes into added time to send Greece to the FIFA World Cup round of 16 for the first time in their history.
Fernando Santos's side looked to be heading home as the game moved beyond 90 minutes, Wilfried Bony's 74th-minute strike having undone some superb work from Greece after Andreas Samaris's 43rd-minute strike crowned a committed and canny showing.
However, Giovanni Sio was penalised for impeding Samaras in the box, and the Celtic FC forward showed glacial calm to clip his spot kick inside Boubacar Barry's right-hand post.
Greece had showed fortitude in Fortaleza, after first Panagiotis Kone and then goalkeeper Orestis Karnezis were forced to go off injured in the first half. Ivory Coast were more stylish, but Greece showed real verve on the counter.
José Holebas drove brilliantly against the crossbar on 34 minutes, and substitute Samaris went one better, pouncing to dispossess Cheick Tioté after a weak touch and swiftly exchanging passes with Samaras before racing into the box to fire low past Barry.
Lazaros Christodoulopoulos fired wide and Dimitris Salpingidis stung Barry's palms with a shot from distance early in the second half but the most heroic work was being done by the Greek defence, with Kostas Manolas putting in a typically brilliant last-ditch challenge to deny Salomon Kalou as he raced through on goal.
With Ivory Coast abandoning their inhibitions, space opened up on the break, Giorgos Karagounis setting the crossbar shuddering again with a mighty drive from distance.
However, they were undone in an instant, a quick ball into the box and a neat pull-back from Gervinho setting up Swansea City AFC striker Bony to stroke the ball past replacement goalkeeper Panagiotis Glykos. Greece did not buckle, though, with Samaras's goal providing a storybook ending.