Angelos Charisteas’ opener, 42, was cancelled by Ruben De La Red, 61, and Daniel Guiza headed the winner just two minutes before the final whistle.
The Spaniards won all of their group stage games to finish at the top of group D and face World Champions Italy in the quarter finals.
Manager Luis Aragones made 10 changes on his formation as Andres Iniesta was the only regular starter who kept his place against Greece.
The Greek wanted to restore their pride after losing their first couple of games. Charisteas broke the deadlock as he met Giorgos Karagounis’ free kick with a well placed header just before the interval.
Spain found their pace in the second half and De La Red volleyed the equalizer from close range.
And just a few seconds before the final whistle La Liga’s top scorer, Daniel Guiza, scored his first international goal to maintain Spain’s perfect run.