Teenager Cesc Fabregas came off the bench to guide Spain into the last 16.
Fabregas is the youngest Spanish player to appear in a World Cup
Tunisia had taken a surprise lead on eight minutes after Joahar Mnari beat Iker Casillas at the second attempt.
But on 71 minutes Ali Boumnijel spilled Fabregas' shot allowing Raul to score, with the Arsenal midfielder then setting up a goal for Fernando Torres.
The Atletico Madrid striker scored his third goal of the tournament when he won and scored a stoppage-time penalty, a spot-kick Boumnijel almost saved.
The win sent Spain to the top of Group H with six points, though Tunisia still have a chance of qualifying.
It was Spain coach Luis Aragones' decision to introduce Fabregas - the youngest Spanish player to appear in a World Cup - and striker Raul at the beginning of the second half that turned the game.
Until then Tunisia had frustrated Spain, through some clever tactics as well as brave defending, masterminded by Bolton centre-back Radhi Jaidi.
Indeed the North African side had taken the lead with their very first attack.
Torres is Germany 2006's leading goalscorer after two games
It was a goal that owed everything to the persistence and skill of Zaid Jaziri, who after brushing past Carles Puyol, beat three other Spanish players before picking out the advancing Mnari.
The Nuremberg midfielder's volley was parried by Iker Casillas, but Mnari made no mistake from the rebound.
David Villa spearheaded Spain's attempts to pull level in the first half, going close with a free-kick and then releasing Torres with a clever pass.
For a split second Torres glimpsed goal, before Hatem Trabelsi moved in to outmuscle the Atletico Madrid striker.
As well as providing defensive cover, Trabelsi was just as keen to scamper forward to give Tunisia a useful attacking outlet on the right.
Tunisia rode their luck at times - Luis Garcia flicking a header wide from Xavi's free-kick after the Liverpool forward had been fouled by Anis Ayari.
Garcia's Liverpool team-mate flashed a long-range shot narrowly wide and on the stroke of half-time Ayari headed Xabi Alonso's header off the line.
But Fabregas's arrival changed the game with the midfielder having an immediate impact, thumping a shot goalward that Boumnijel did well to beat away.
Soon after Aragones went for broke, throwing on his third substitute as Real Betis winger Joaquin replaced Valencia striker David Villa.
Joaquin provided the pass for a second Fabregas shot that set up Spain's equaliser, an effort Boumnijel was unable to hold, allowing Raul to score from close range.
A rush of blood to the head by Boumnijel proved fatal to Tunisia's hopes of coming away with a point as Fabregas released Torres.
Boumnijel was caught hopelessly out of position allowing Torres to flick the ball into the unguarded net.
Late on Torres was fouled by Alaeddine Yahia as he jumped for the ball, though the Spain forward was slightly lucky to score with the penalty, a goal that means he is the World Cup's current top goalscorer.
Spain: Casillas, Sergio Ramos, Puyol, Pablo, Pernia, Xavi, Alonso, Senna (Fabregas 45), Luis Garcia (Raul 45), Torres, Villa (Joaquin 56).
Subs Not Used: Albelda, Antonio Lopez, Canizares, Iniesta, Juanito, Marchena, Reina, Reyes, Salgado.
Booked: Puyol, Fabregas.
Goals: Raul 72, Torres 76, 90 pen.
Tunisia: Boumnijel, Haggui, Jaidi, Ayari (Yahia 56), Trabelsi, Mnari, Bouazizi (Ghodhbane 56), Chedli (Gmamdia 79), Namouchi, Nafti, Jaziri.
Subs Not Used: Ben Saada, Chikhaoui, Essediri, Jemmali, Kasraoui, Melliti, Nefzi, Saidi, Santos.
Booked: Ayari, Trabelsi, Jaidi, Gmamdia, Jaziri, Mnari.
Goals: Mnari 8.
Ref: Carlos Eugenio Simon (Brazil).
Fifa man of the match: Xabi Alonso
Spain are now unbeaten in 24 matches. Their last defeat came on 22 June 2004, when Portugal beat them 1-0 at Euro 2004.
Raul joined Butragueno, Hierro and Morientes as the fourth Spanish player to score five World Cup goals. Raul also became the 18th player to score at three or more World Cups. Fernando Torres is now top scorer of the 2006 World Cup with three goals.
Tunisia are on a streak of 10 matches without a win at the World Cup. This string started after they became the first African nation to gain a World Cup victory, when they beat Mexico 3-1 in 1978.
Trivia stats source: Infostrada Sports