Mexico had looked the sharper and more inventive side in the first half, and could have taken an earlylead when Itumeleng Khune spilled Paul Aguilar'scross on virtually their firstattack.
Midfielder Xavi Alonso netted the winner in the 107th minute when his curling free-kick evaded his own players, the South African defenders and unsighted goalkeeper ItumelengKhune.
Diego Forlan capped an impressive performance with two goals - the first a 30-yard deflected strike, the second a well-taken penalty after Luis Suarez had been fouled by goalkeeper ItumelengKhune, for which he was red carded - and Alvaro Pereira added a late third.