Tunisia were looking to hang on to record only their second victory in World Cup Finals history and their first since 1978, but a Raul equaliser in the 71st minute and then a Fernando Torres winner five minutes later condemned the Africans to another loss.
Atletico Madrid striker Torres then iced the comeback win with a 90th minute penalty after he himself had been fouled in the box by St Etienne defender Alaeddine Yahia.
Real Madrid striker
Raul, who had come on as a substitute at half time scored after fellow half time substitute Cesc Fabregas had a shot saved by Tunisian keeper Ali Boumnijel, only for the ball to bobble out with the evergreen striker pouncing to stab his shot goal bound.
Raul makes an impression
Arsenal midfielder Fabregas then sent a beautiful ball through to Torres, and with Boumnijel coming way off his line, the Atletico Madrid striker jinked and sent the ball into the back of an unmarked goal.
Torres, who is now the leading goal scorer in the tournament with three goals, sent his penalty along the ground to the right of keeper Boumnijel, with the keeper guessing the correct direction, but diving over the ball as it skimmed across the turf.
Earlier, Tunisian midfielder Jaouhar Mnari scored the opening goal of the match in the 8th minute after striker Zied Jaziri had done some excellent work in riding a Carlos Puyol tackle, getting into the box, and then sending a cross towards the penalty spot.
The Nuremberg based Mnari arrived on the scene with a late run and hit a shot straight at Spanish keeper Iker Casillas who could only parry the ball back into the path of Mnari who this time beat the Real Madrid custodian from closer range.
The Tunisian celebrations wouldn't
last the night
Down 1-0 at the break, Spanish coach Luis Aragones made the double substitution and then his final change with 33 minutes still left to play, when he brought on the winger Joaquin for misfiring striker David Villa, the change of formation and tactics working beautifully.
Spain now lead Group H and must be favourites to finish top as they have a positive goal difference of 6, and play the lowly Saudi Arabia in their final group match.
Tunisia are still in with a chance to qualify for the second round for the first time, but anything less than a win in their last match against Ukraine will not be enough.