Spain's win also ensured Vicente del Bosque's side equalled Brazil's all-time record of 35 matches unbeaten.
The game in Bloemfontein offered a contrast in styles, with Spain relying on a short-passing game and plenty of possession, while South Africa looked to hit their European opponents with speed on the counterattack.
Spain had the better of the first-half chances, with Albert Riera testing Khune with a thundering long-range free-kick.
Khune also did well to deny Fernando Torres with a one-handed save, while Villa might have done better with a couple of headers.
South Africa started to cause Spain real problems, but were hindered by a lack of composure when they glimpsed a sight of Pepe Reina's goal.
Having survived Spain's early onslaught, Parker sliced wide after good work from Everton's Steven Pienaar.
Parker and Pienaar then combined to set up Modise, who scuffed his shot wide.
Having matched Spain in the first half, South Africa found themselves chasing the game following a frenetic passage of play early in the second half.
Mokoena's late challenge on Fabregas gave away a penalty, but Khune produced a superb save to beat away Villa's powerful shot and then got up quickly to smother Carlos Puyol's effort from the rebound.
But within a minute Villa had atoned for his penalty miss, controlling a floated pass and volleying past Khune, although South Africa defenders appealed, claiming the Valencia forward had used his arm to cushion the ball.
Substitute Llorente sealed the win in the 72 minute when he slid the ball past Khune after South Africa failed to clear a free-kick.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.