Georgios Samaras played the hero for Greece as he won and scored a penalty in injury time to send his side into the knockout stages of the World Cup for the first time in their history.
Greece came into the game in Fortaleza still searching for their first goal of the tournament, but it finally came just before half-time as Andreas Samaris found the back of the net.
But it looked like it would all be in vain as Wilfried Bony was introduced just after the hour mark and with 15 minutes left levelled things with a calm finish.
However in injury time Samaras was tripped by Giovanni Sio in the box and the striker held his nerve from the spot to confirm Greece as Group C runners-up, meaning they will now face Group D winners Costa Rica in their final 16 clash.
In a tense opening ten minutes it was Ivory Coast doing most of the pressing; however the likes of Didier Drogba and Gervinho couldn't find a way past a resolute Greece defence.
And at the other end things weren't looking much better for Greece as on 11 minutes Panagiotis Kone went down injured and had to be replaced by Samaris.
However Greece were trying their best to impose themselves on the game and after quarter of an hour Ivorian goalkeeper Boubacar Barry was forced to dive bravely at Dimitris Salpingidis' feet after Vasilis Torosidis' teasing cross.
But Greece were forced into another early substitute as this time goalkeeper Orestis Karnezis went down injured with no one around him on 18 minutes. He popped back up after some treatment from the physio but could only last another six minutes before being replaced by Panagiotis Glykos who was winning just his third international cap.
And in between Karnezis going down and being replaced Ivory Coast should have fashioned the game's first real chance when Yaya Toure burst into the box, only for the Manchester City man to over hit his pass to Drogba.
Greece almost went ahead just after the half hour mark as Samaras slipped Jose Holebas into space only for his shot to cannon off the crossbar and out to safety. In the ensuing panic Greece were awarded a free-kick on the edge of the box but Giorgos Karagounis' low drive was well held by Barry.
But on the stroke of half-time Greece did find the back of the net, just their third ever World Cup goal. A poor pass from Newcastle midfielder Cheick Tiote was pounced on by Samaris and after playing a one-two with Samaras the substitute coolly finished past Barry.
After the break Tiote looked to make amends but his drive from the edge of the area was gathered by Glykos, and at the other end Lazaros Christodoulopoulos did well to make space for himself before firing wide from just inside the box.
And in fact it was Greece who looked like grabbing another goal as first Salpingidis forced Barry to turn his drive over the bar before Karagounis rattled the bar with a long-range effort.
It was Christodoulopoulos' turn to close next, his free-kick landing on the roof of Barry's net but they couldn't rest on their laurels at down the other end as Souleymane Bamba headed a Toure corner narrowly wide.
But it wasn't long after that Ivory Coast found themselves level, substitute Bony calmly side footing home after being set up by Gervinho.
Greece threw everything at Ivory Coast in an attempt to find a crucial winner and with time up Samaras was bundled over in the box and stepped up to find the bottom corner of Barry's net to send his countrymen wild.
Greece 2
Samaris 42, Samaras 90
Ivory Coast 1
Bony 74
Referee: Carlos Vera
Attendance: 59,095
Greece (4-3-3): Karnezis (Glykos 24), Torosidis, Papastathopoulos, Manolas, Holebas, Christodoulopoulos, Maniatis, Karagounis (Gekas 78), Kone (Samaris 11), Salpingidis, Samaras
Subs not used: Tzavelas, Moras, Tziolis, Mitroglou, Vyntra, Fetfatzidis, Katsouranis, Tachtsidis, Kapino
Ivory Coast (4-3-3): Barry, Aurier, Kolo Toure, Bamba, Boka, Die, Tiote (Bony 61), Kalou, Yaya Toure, Gervinho (Sio 83), Drogba (Diomande 78)
Subs not used: Gbohouo, Viera, Zokora, Bolly, Akpa Akpro, Konan, Gradel, Djakpa, Sayouba
↧