Vieira headed in at the far post in the 83rd minute after a free-kick had been deflected towards his own goal by Spain's Xabi Alonso [ Images ].
Vieira's header got flicked off Spain's Sergio Ramos [ Images ] on its way into the net.
Zidane finished things off in style in stoppage time, beating goalkeeper Iker Casillas [ Images ] after a swift counter attack.
France now meet Brazil [ Images ] in the quarter-finals on Saturday, a repeat of the 1998 final, won by the French.
France, written off by many as too old, came back from a goal down.
Spain had opened the scoring on 28 minutes, striker David Villa [ Images ] firing home from a penalty after Pablo Ibanez had been fouled by Lilian Thuram.
France reacted in style four minutes from halftime.
Lively winger Franck Ribery [ Images ] raced on to a fine through ball from Vieira and rounded keeper Casillas to score his first goal for France with a cool finish.
Spain, eager to shake off their tag as under-achievers and to erase memories of their last competitive meeting with France, when Raul missed a last-minute penalty in a 2-1 defeat in the quarter-finals of Euro 2000, looked fresher and more imaginative throughout the first half.
After a cautious start from both sides, Spain were the first to threaten when left back Mariano Pernia curled a free kick just over the left upright from 25 metres on nine minutes.
France, relying on their trademark, watertight back four, showed little initiative up from until both Ribery and Vieira failed to connect with a low Thierry Henry [ Images ] cross midway through the half.
Everything was a place for a dramatic second-half fight after France levelled shortly before the break.
France went close in the 52nd minute when a chipped volley by Florent Malouda [ Images ] enabled Casillas to show his class with a spectacular one-handed save.
Luis Aragones then tried some fresh legs in an effort to break the deadlock, taking off Raul, who won his 99th cap on his 29th birthday in disappointing fashion, and Villa to make way for Luis Garcia and Joaquin.