Thembinkosi Lorch struck in the closing stages to stun Javier Aguirre's side and keep alive their challenge to become continental champions for just the second time.
Stuart Baxter's side came in for heavy criticism during the group stage as they scraped through despite losing to Ivory Coast and Morocco, but they responded with a disciplined and clinical display that saw them keep Mohamed Salah quiet and make the most of Lorch's late opening.
They will face Nigeria in last eight after the Super Eagles earlier saw off Cameroon 3-2 in a thriller.
Percy Tau's dipping free-kick was brilliantly tipped over by Mohamed El-Shenawy as the half begun in lively fashion.
The best chance of the first 45 minutes fell to Trezeguet, who could only shoot tamely at Ronwen Williams after being set up by Salah following a quick break.
Trezeguet was again set up six yards from goal after a brilliant pass from Salah early in the second half, but his finish was once more a poor one.
Egypt were beginning to assume more control on proceedings but creating chances was still posing a problem, and South Africa captain Thulani Hlatshwayo was only feet from finding the bottom-left corner with a header from a Lorch delivery.
As Egypt continued to throw caution to the wind, they were stung on the break with five minutes of normal time to go. A well-worked move saw Lebo Mothiba stride into space and square the ball for Lorch, who kept his composure to side-foot past El-Shenawy and send his side into the last eight.