The Red Devils, with many regulars rested, were largely toothless throughout as Maqassa put up a brave fight despite being relegated to the second division for the first time since sealing promotion to the Egyptian Premier League more than a decade ago.
Ahly did create some chances, however, as they laid siege to the area of a defensive-minded Maqassa side.
In the first half, a bouncing header from young striker Ahmed Gharib went just over the crossbar and Mozambican winger Luis Miquissone was denied by the keeper from a good scoring position.
The keeper was also called into action early in the second half, palming away a powerful header.
Ahly then struggled for openings until the stoppage-time penalty brought relief for the club as a defender was penalized for a handball. Maqassa's Hesham Hafez was red-carded for dissent after the referee awarded the penalty following a VAR review.
Rabia fired low into the bottom corner, with the keeper unable to stop his effort despite diving the right way.
Ahly set up a quarter-final meeting with Arab Contractors as they seek to avoid ending the season empty-handed.
They lost to Morocco's Wydad in the African Champions League final and virtually lost hopes of competing for the domestic league title, which Ahly's arch-rivals Zamalek are in pole position to win for a second consecutive season.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)
Short link: