Georgios Samaras scored a goal off a penalty kick in extra time with less than a minute left in the game, meaning Greece advances to the Round of 16.
Samaras was knocked down in the penalty box by an Ivory Coast defender, prompting the ref to call the foul.
Andreas Samaris had scored in the first half in the 42nd minute, putting Greece up 1-0 at halftime.
Wilfried Bony scored in the middle of the second half to tie the game 1-1.
Both teams were playing for the opportunity to advance, with an eye on the concurrent Japan-Colombia game.
Japan lost 1-4, meaning the winner of the Greece-Ivory Coast would advance.
A draw would have seen Ivory Coast advance.
See an Associated Press recap below.
Greece advances after late penalty at World Cup
FORTALEZA, Brazil—Georgios Samaras scored an injury-time penalty to put Greece into the second round of the World Cup with a 2-1 win over Ivory Coast.
Samaras was adjudged to have been brought down by substitute Giovanni Sio and Samaras calmly slotted in the spot kick for the win that puts Greece through to the knockout stage. Ivory Coast would have advanced with a draw.
Substitute Wilfried Bony had equalized for Ivory Coast in the 74th, beating goalkeeper Pangiotis Glykos from close range after being set up by Gervinho.
The Greeks had taken the lead just before halftime through substitute Andreas Samaris.
Veteran striker Didier Drogba started for Ivory Coast along with Yaya and Kolo Toure despite the recent death of their brother Ibrahim. The Ivorians wore black armbands as a sign of mourning.