Goals from David Villa, who minutes earlier had missed a penalty, and Fernando Llorente were enough to see of a spirited Bafana side who had chances of their own.
The home side finished second in the pool and will now move forward to play the top team in Group B, while Spain made it a perfect three wins from three, in the process breaking Australia’s record of 14 consecutive wins in international football.
The Spaniards also equalled the most number of games without defeat, 35, a mark they can beat if they win their semifinal.
Itumeleng Khune was into the action early as Albert Riera stung his palms from 35-yards with a blistering free-kick that was headed for the top corner before Khune’s intervention.
Macbeth Sibaya collected an early yellow card for a foul on Cesc Fabregas that rules him out of the semifinals.
After chasing shadows early on, Bafana came more into the match as the half wore on and began to exert pressure of their own with a succession of corners and slick passing in midfield.
But it was Spain who came closest next as Torres was played in behind the home defence, but the Liverpool man’s attempted chip over Khune struck the goalkeeper’s arm and Matthew Booth was able to clear ahead of the on-rushing Fabregas.
Then followed two excellent chances for the home side. First Parker blasted over after being set free by Steven Pienaar and then Teko Modise scuffed his shot from the edge of the area after more excellent work from Pienaar and Parker.
Spain ended the half with the final chance as a Torres break down the right set up David Villa, whose shot was over the bar.
Xavi fired just wide with an early free-kick in the second half, and Spain should have taken the lead early in the second half when Mokoena brought down Fabregas in the area, but Villa saw his effort saved by Khune.
However, he made amends just afterwards in the 52nd minute when he steered the ball past the Bafana Bafana keeper after brilliant control with his chest.
Bafana pressed forward in search of an equaliser, but found it hard to create opportunities against the well-marshalled Spanish defence. Modise was set up by Masilela, but fired his shot straight at a defender, while Parker just failed to get on the end of a Siboniso Gaxa cross.
Spain switched to one up front after the departure of Villa and Torres from the game, attempting to soak up the Bafana pressure and hit them on the break with their lightening counter-attacks.
The Spanish second came via the substitute Llorente, after a low free-kick from the left caught the defence napping and the Athletic Bilbao striker was able to turn the ball past a helpless Khune.
Parker almost got on the end of Pienaar’s cross after the Everton man was set free, while Katlego Mashego replaced the injured Macbeth Sibaya with seven minutes to go.
Soon afterwards Parker tested the palms of Spain goalkeeper Pepe Reina with a shot from just inside the area, while Khune saved low to his right from substitute Santi Carzola.