A brace from in-form striker Mohamed Sherif spared Ahly's blushes against Masry after the defending champions claimed a hard-fought 2-1 victory in the Egyptian Premier League on Tuesday.
Sherif netted for the third game in his last four appearances to power Ahly to a much-needed win after they were surprisingly put on the back foot for most of the game as a bold Masry side mounted relentless pressure throughout.
The 25-year-old, who was also Ahly's two-goal hero in their Cairo derby victory over Zamalek earlier this month, opened the scoring after 11 minutes but Omar Abdel-Wahed brought Masry level on the stroke of halftime.
Sherif scored again three minutes past the hour mark to prove the difference and help a depleted Ahly side, who are missing their entire backline due to injuries, close to within three points of leaders and arch-rivals Zamalek, who played two games more.
The Egyptian international took his tally to nine goals in 15 league matches this season.
Masry remain fourth on 29 points from 19 matches.
Both sides had chances to score an early opener before Sherif made the breakthrough on 11 minutes, running onto a long ball from young left-back Ahmed Nabil to beat the offside trap and race clear.
His initial effort was blocked by the advancing Ahmed Daadour but the keeper collided with a Masry defender and the rebound fell kindly for Sherif to slide it into an empty net.
Ahly fans would normally expect their side to quickly kill off their opponents, just like what they did against Enppi in their previous match, but they were instead pegged back as Masry mounted an onslaught.
Masry winger Ahmed Refaat wreaked havoc down the left as Ahly's makeshift defence was repeatedly exposed, with Masry going close on several occasions.
Lone striker Ahmed Gomaa headed against the side netting when unmarked at the far post before forcing a superb one-handed save from Ahly goalkeeper Mohamed El-Shennawi with a shot from a narrow angle.
Masry deservedly equalised just before the half-time whistle when a corner was flicked to the far post, where Abdel-Wahed was found unchallenged to fire home on the half-volley.
It was the same story in the second half, with Ahly sitting back to soak up pressure and Masry piling on pressure.
However, Ahly netted against the run of play to restore their advantage in the 63rd minute after a flowing three-man move.
Hussein El-Shahat, who was otherwise a peripheral figure, slipped a pass to Akram Tawfik on the right to send in a low cross that Sherif turned into the net from close range.
Masry almost snatched a draw at the death when a header from substitute Mohamed Grendo went just wide while Ahly's Taher Mohamed Taher missed an open net after rounding the keeper at the other end.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)