The Kaiser Chiefs forward beat Victor Valdes after 57 minutes to stun Vicente del Bosque's side, who produced one of their poorest performances in recent memory to lose only their second match in more than three years.
Spain took the initiative from kick-off but, aside from two efforts from David Villa that were ruled out for offside and a wayward shot from Andres Iniesta, did not cause their opponents many problems, despite maintaining 92 per cent possession in the opening 20 minutes.
It was Gordon Igesund's side who fired the first warning shot, Oupa Manyisa thumping the bar after 19 minutes with an effort from outside the area which had deflected off Sergio Ramos.
Spain created their best chance of the half on 27 minutes, Fernando Llorente sending a free header just wide of the post after a ball from Alvaro Arbeloa, and a couple of minutes later La Roja had another goal ruled out for offside, this time Pedro being caught out.
On the stroke of half-time, Bongani Khumalo missed the best chance of the game, glancing a near post header just wide after Parker had swung in a corner.
Just after the re-start, the hosts squandered another glorious chance. Substitute Siphiwe Tshabalala released Tokelo Rantie, who ran towards goal unchallenged but got too much power on his shot, which went narrowly over the bar.
Nacho Monreal should have done better for Spain when a through ball from Iniesta allowed him to go face to face with Itumeleng Khune, but the Arsenal full-back could only shoot at the goalkeeper's legs.
Then came the goal South Africa deserved.
South Africa strike
Full-back Thabo Matlaba got down the left wing and cut the ball back to Kamohelo Mokotjo, who split the Spain defence with a one-touch pass, and Parker lifted the ball over Valdes' outstretched hand and into the far corner.
Spain's response to going behind was to bring on Alvaro Negredo for Villa. The Manchester City forward had a positive impact but was unable to take either of the two chances that fell to him, the first a distance shot which flew over the bar, the second a soft attempt from inside the area which allowed Khune to save.
With 15 minutes remaining, Del Bosque made his fifth and final substitution, withdrawing Iniesta for Koke. But barely a minute later Valdes, who had replaced Casillas at half-time, fell to the floor in pain with an apparent calf injury.
The Napoli goalkeeper was called into action immediately, denying Rantie when the striker was clean through. With time running out, Spain struggled to create a clear attempt on goal.
A minute and a half into injury time Cazorla caught sight of goal from 25 yards out but Khune was able to catch the attempt comfortably.
And the goalkeeper came to his side's rescue again with a minute left of the game, pushing away a close-range effort from Albiol.