Mohamed Salah struck a fine 90th-minute winner as Egypt defeated rivals Tunisia 3-2 in Friday's Africa Cup of Nations qualifier at the Borg El Arab Stadium, Alexandria.
Naim Sliti opened the scoring in the 14th minute for the visitors, but his opener was cancelled out when Trezeguet levelled the match for the hosts just after the half-hour mark.
Baher El Mohamady fired Egypt ahead on 60 minutes, but Sliti thought he'd rescued a point for the Carthage Eagles with his second in the 72nd minute.
However, there was a final twist as Salah dinked the ball about the sprawling Farouk Ben Mustapha after a neat interplay with Salah Mohsen.
After celebrating his fourth goal of the qualifying campaign, the Liverpool superstar was then booked for removing his shirt.
His strike was the 39th of his international career, taking him above Mohamed Aboutrika into third outright in Egypt's all-time scoring charts.
Both nations had already qualified for next year's showpiece in Cameroon during the last round of matches in October, and the pair are now on 12 points with one match to play.
Tunisia lead the pool by virtue of having scored more away goals than the Pharaohs.
Group J's two other teams, eliminated Eswatini and Niger, meet in Manzini on Sunday.