Ahly were almost undone by two goalkeeping blunders but striker Marwan Mohsen came to their rescue in stoppage time as they salvaged a 2-2 draw at home to Emirati club Al-Wasl in the first leg of the Zayed Champions Cup round of 16 in Alexandria on Sunday.
The Red Devils took a first-half lead via a free-kick from veteran right-back Ahmed Fathi but they were stunned with two late goals from Al-Wasl's Brazilian duo Caio and Fabio Lima, with substitute keeper Sherif Ekramy the culprit.
Ekramy started on the bench but was introduced in the first half after first-choice goalie Mohamed El-Shennawi picked up an injury amid doubts over his availability for the crucial African Champions League final first-leg against Tunisia's Esperance on Friday.
However, Egyptian international Mohsen scored on the turn just before the final whistle to keep Ahly's hopes alive of advancing to the quarter-final when they face Al-Wasl away from home in the second leg on 22 November.
With one eye on the anticipated Esperance clash, Ahly coach Patrice Carteron rested several regulars, including Moroccan marksman Walid Azaro and in-form winger Walid Soliman.
Al-Wasl had the better of the first half, going close twice as Ahly's shaky defence was repeatedly exposed.
El-Shennawi thwarted forward Caio in a one-on-one after 10 minutes and fellow Brazilian Lima shot wide when well-positioned to score four minutes later.
At the other end, Ahly's solitary chance fell to winger Mohamed Sherif, whose tame shot from inside the area was easily collected by the keeper.
But Ahly still went to the locker room 1-0 up, thanks to an angled free-kick from Fathi which eluded a crowd of forwards and defenders to nestle into the corner of the net.
The second half was an end-to-end affair, with both sides going close on a number of occasions.
Ahly needed a goal-line clearance from rookie central defender Ahmed Alaa to keep their lead intact while Mohamed Sherif wasted two chances at the other end, including a close-range header with the goal at his mercy.
Caio leveled the score in the 82nd minute in bizarre fashion when a cross bounced off his chest and struck the head of the poorly-positioned Ekramy before looping into the back of the net.
Lima made it 2-1 four minutes later as Ahly were again exposed on the breakaway, curling a shot home from the edge of the area past Ekramy who inexplicably charged out towards the edge of the six-yard box.
But Ahly escaped a third defeat in four matches when the unmarked Mohsen made the most of a flick from Ahmed El-Sheikh to fire home on the turn.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)