Amr Gamal scored twice as Al Ahly came from behind to beat Coton Sport 3-1 and earn a place in the CAF Champions League quarter-finals.
Al Ahly, record eight-time winners of the competition, knew they had to win to stand any chance of progression from Group D.
That did not look likely when Coton Sport – who exit the competition without registering a point – took a 12th-minute lead courtesy of Ahmed Fathy's own goal.
But Gamal levelled the match within three minutes and the hosts were ahead at half-time thanks to Abdallah Said 12 minutes before the break.
Gamal, who had not started any of Al Ahly's previous five group matches, sealed the victory nine minutes into the second half.
The win was enough to put Al Ahly through as runners-up after Zanaco, who had started the day top and only needed a point to progress, dramatically slipped to third after losing 1-0 away to Wydad Casablanca.
Zanaco were up against it when Taonga Bwembya was sent off just before the hour mark for a second booking and Achraf Bencharki's strike 10 minutes later gave Casablanca – winners of the tournament in 1992 – a victory that ensured they finished top.
Al Ahly and Zanaco had identical head-to-head records as they sat one point behind Casablanca, with the Egyptians going through on goal difference.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.