The Egyptian Premier League giants played host to former Ugandan champions KCCA at the Borg El Arab Stadium needing three points to finish at the top of Group A standings.
KCCA's hopes of reaching the knockout stages had already been dashed after winning two games out of five matches in their group.
- Milan's 'Magic Mike' Maignan making Juventus look like losers in Donnarumma PSG transfer
- No Trent, no Robertson, no sweat - Liverpool's title credentials beyond dispute after show of squad strength
- Ex-Man Utd star Herrera eclipsing Messi, Neymar and Mbappe at PSG
- Odegaard on target as Arsenal 'change the narrative' by battling their way to vital victory at Burnley
The hosts took an early lead through their Moroccan striker Walid Azarou, who scored 23 minutes into the game to make it 1-0 to Al Ahly, but Jackson Nunda levelled matters for KCCA five minutes before half-time.
An enthralling second half followed as Souleymane Coulibaly restored Al Ahly's lead five minutes after the restart, before Peter Magambo equalized for KCCA in the 54th minute to make it 2-2.
The hosts then took control of the game and they grabbed two late goals through Azarou and Salah Mohsen to make it 4-2.
Allan Okello grabbed a late goal for KCCA in the closing stages of the game which proved to be a mere consolation for the visitors as Al Ahly emerged 4-3 winners on the night.
Rollers were hoping to end their group stage campaign on a high having already been eliminated from the continental tournament.
The two teams struggled to create chances in the first half and the score was 0-0 at the interval following a tightly contested first half in Gaborone.
Rollers, who were making their debut appearance in the group stages of the prestigious competition, continued to frustrate the two-time Champions League winners in the second half.
Ultimately, the encounter ended in a 0-0 stalemate with Rollers and Al Ahly sharing the spoils on the night.
The final round of the group stages saw Al Ahly finish top of Group A with 13 points from six games, while Esperance settled for a second place having collected 11 points, and both teams advanced to the quarter-finals.
Al Ahly will take on Algerian side ES Setif in the quarter-finals, while Esperance are scheduled to face DR Congolese giants TP Mazembe.