Spain 1 France 3
Vieira's close-range header eight minutes from time broke the hearts of Spanish fans before Zidane capped a wonderful evening for Les Bleus by striking France's third deep into injury time.
David Villa had given the Spaniards a 28th-minute lead from the penalty spot after Lilian Thuram had bundled over Pablo inside the area before Franck Ribery equalised shortly before half-time.
Spain promised to erase the nation's reputation as World Cup underachievers but despite dominated the opening half they struggled to show their true potential when it truly mattered.
Luis Aragones' second-half substitutions backfired with Luis Garcia and Joaquin failing to inspire Spain to victory.
Raymond Domenech's side had been unconvincing in the group phase, drawing with Switzerland and South Korea before defeating Togo to finish second in Group G, but they never gave up and were rewarded.
They now face Brazil, a replay of the 1998 World Cup final, which saw France come out triumphant.
Arsenal's Cesc Fabregas and Raul were both included in the starting XI with the latter placed up front alongside Villa and Fernando Torres in an attack-minded Spanish side.
Zidane returned from suspension to captain his side in what could have been his last game had it gone against France.
Spain dominated possession in the early stages of the game and would have gone in front had Mariano Pernia's curled free-kick not fizzed inches wide of goalkeeper Fabien Barthez's far post.
At the other end, Thierry Henry's right-footed effort from the edge of the area proved an easy catch for goalkeeper Iker Casillas.
Spain applied pressure in midfield and surged forward but struggled to break their rivals' well-drilled defence.
For all their superiority, Aragones' men could have trailed in the 15th minute had Pernia not made a vital block from Zidane's bullet shot from inside the area.
France finally put together a good move midway though the first half, with Zidane's long pass finding Henry at the far post, who knocked the ball into the danger zone but both Ribery and Vieira failed to connect.
The prayers of the Spanish fans were answered soon afterwards however when Italian referee Roberto Rosetti pointed to the penalty spot as Thuram fouled Pablo with a clumsy challenge from behind.
Villa found the right-hand corner of the net and there was little Barthez could do to deny Spain taking the lead.
Stunned, Les Bleus pressed forward in search of the equaliser and they got it four minutes before the break as they finally broke the offside trap.
Vieira's perfect pass sliced Spain's defence wide open and found an unmarked Ribery, who surged inside the area and dribbled round Casillas to slot his shot into the back of the net.
France picked up where they left off after the restart and should have gone in front had Casillas not made a spectacular one-handed save from Florent Malouda's close-range effort.
An unhappy Aragones wasted no time and made a double substitution with Luis Garcia and Joaquin replacing Raul and Villa.
But it was their rivals who were still calling the shots, with the ever-present Ribery delivering a testing ball towards the dangerzone but there was no-one at the end.
On the hour mark, Eric Abidal anticipated Torres inside the box to clear Joaquin's deadly cross from the right.
Unable to force their way through the middle Spain found a more successful route out wide and were unlucky not to go in front in the 68th minute.
Luis Garcia latched onto Pernia's cross from the left but his header bounced onto the ground to go high over the crossbar.
Aragones played his last card shortly after, with Marcos Senna replacing Xavi, who had failed to make much of an impact in midfield.
Domenech brought on forward Sidney Govou for Malouda with 15 minutes remaining but it was Spain that looked more threatening.
Joaquin's angled strike from inside the area went inches wide of the near post while Govou tried his luck from the distance but fired off-target.
With eight minutes remaining, Carles Puyol brought down Henry to give France a set-piece opportunity and it proved costly. Zidane floated in the free-kick which took a deflection into the patch of Vieira whose header went in off the leg of Sergio Ramos.
It proved a hammer blow for the Spaniards who failed to hit back and conceded another goal in stoppage time as they pushed forward.
Zidane got past two defenders before firing towards the far post to mark a wonderful evening for Les Bleus.