10 minutes after the restart, Salah released Trezeguet behind South Africa's backline with a defence-splitting pass, but his first-time shot was saved steadily by Ronwen Williams.
South Africa's player celebrate their opening goal during the 2019 Africa Cup of Nations (CAN) Round of 16 football match between Egypt and South Africa at the Cairo International Stadium in the Egyptian Capital on July 6, 2019.
The stunning elimination marked Egypt's worst-ever performance as hosts.
Egypt will lock horns with South Africa on Saturday as they enter the knockout stages of the continental competition, but whether or not they will have Salah at their disposal remains to be seen.
Nigeria earlier beat defending champion Cameroon 3-2 in a wild last-16 game.
The Pharaohs wasted a glorious chance just two minutes later.
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.
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 progressed to a quarterfinal against Nigeria, while Egypt and Salah were left bitterly disappointed with an early exit from their home tournament.
But Egypt could have still taken the lead had it not been for a surprise miss from Trezeguet, one of the team's standout performers of the tournament.
Salah, who has had a cold, was told by Egypt coach Javier Aguirre not to "worsen his condition" by training.
The match looked set for extra time, but on 85 minutes South Africa struck on a quick counter attack: Lebo Mothiba beautifully played in Lorch, who this time showed great composure to slide a shot beyond the 'keeper and provide the decisive moment.
Peru stun Chile 3-0 to reach Copa America final
While Casemiro hailed the forward's quality, the midfielder also praised the talent in Brazil's squad. And we're working towards a win, although with a lot of respect towards our opponents.
Michigan Rep. Justin Amash quitting Republican Party
He will now be able to avoid the possibility of being primaried and can run in the general election as an independent. A number of Republican challengers emerged after Amash's impeachment call, including state Rep.