Ahli trailed to Andre Senghor's opener for Ain ten minutes before halftime.
But the visitors overturned the deficit in the second half, thanks to two goals from Faisal Khalil and Brazilian striker Bare in the 49th and the 71st minutes respectively.
Ahli booked a last-four berth after finishing as the best second-placed team in the three groups of the cup.
They have 10 points, three behind leaders Ain, who had already secured a place in the semis.
Egyptian international midfielder Abd-Rabou started on the bench before being introduced three minutes past the hour mark.
He was unlucky not to get on the scoresheet when his superb right-footed lob came off the post.
Abd-Rabou, who joined Ahli from Egyptian club Ismaili on a two-year loan last summer, scored seven goals for Ahli so far in all competitions.