Thembinkosi Lorch scored on 85 minutes to give South Africa a stunning 1-0 victory over Africa Cup of Nations hosts Egypt after a pulsating last-16 clash in Cairo Saturday.
After three woeful group performances, South Africa was rank outsider against the record seven-time African champions, whose line-up included Liverpool star Mohamed Salah.
A seesaw struggle was settled when a swift counterattack allowed Lebo Mothiba to send Lorch through and he fired past goalkeeper Mohamed Elshenawy.
The winners were unrecognisable from the team that struggled in the group stage as they displayed sharpness and desire not previously evident.
South Africa will face arch-rivals Nigeria, who eliminated defending champions Cameroon in Alexandria earlier Saturday, in the quarter-finals.
Salah, who missed some midweek training due to a cold, was generally well policed by a superbly organised South African defence.
Egypt changed three of the side that defeated Uganda to complete Group A with a 100% record, five goals scored and none conceded.
Back came defender Mahmoud Alaa, midfielder Tarek Hamed and forward Marwan Mohsen with Baher Elmohamady, Nabil Donga and Ahmed Hassan dropping to the bench.
South Africa made two changes, both in midfield, from the team that lost to Morocco and squeezed into the second round with the worst record of the best four third-place teams.
In came South African Premiership Player of the Season Lorch and fit-again Dean Furman for Thulani Serero and suspended Themba Zwane.
Bafana Bafana (The Boys) had been woeful in all three Group D matches, barely troubling rival defences, and the public and media slammed the negative tactics of Coach Stuart Baxter.
The England-born coach hinted at a more attacking approach and was true to his word as Percy Tau and Lorch had ambitious long-range attempts at goal within three minutes of the kick-off.
Salah, the reigning African Footballer of the Year, had a shot deflected wide soon after.
Mahmoud ‘Trezeguet’ Hassan, one of the Pharaohs’ stars in the group stage, tormented several defenders just outside the box and induced a foul, but Abdallah el Said botched the free-kick.
The desire of South Africa to attack was evident again on 15 minutes when impressive winger Tau stung the fingertips of Elshenawy with a hard, long-range shot.
Tau came much closer to breaking the deadlock midway through the half with a free-kick that cleared the wall and forced Elshenawy into a brilliant save.
South Africa were looking the likelier side to break the deadlock and a brave block by Ayman Ashraf foiled Lorch.
Mokotjo then unleashed a sizzling low,long-range shot that flew past Elshenawy but finished just off target,
The frustration of Egypt, who scored all five group goals before half-time, was mirrored in the angry reaction of Salah when a free-kick was awarded against him.
Mexico-born Egypt coach Javier Aguirre altered his largely ineffective attack at half-time, bringing in veteran Ahmed Ali for Mohsen.
‘Trezeguet’ squandered a great chance just before the hour, tamely shooting straight at goalkeeper Ronwen Williams after a superb defence-splitting pass from Salah.
Amr Warda, axed from the squad over sexual harassment allegations and swiftly recalled after player pressure, came off the bench on 64 minutes for his second tournament appearance.
South Africa captain Thulani Hlatshwayo headed just wide as he darted on to a free kick with 20 minutes remaining.