The Kenyan champions managed to see off the visitors at the Kasarani Stadium, a game in which Jacques Tuyisenge - who has four goals in the competition - scored twice in 12 first half minutes. Ibrahim Hassan also found the back of the net on two occasions to tie the match at 2-2 at the half-time break.
Goals from 23-year-old Nicholas Kipkirui (51') and Dennis Oliech's 90th-minute strike ensured that Gor Mahia pulled off a historic win against one of North Africa's football's powerhouses.
Oliech came off the bench to score against Zamalek.
The win ensured Gor Mahia were perched at the top of the group after Algeria's Nasr Athlétique de Hussein Dey (NAHD) beat Petro Atletico of Angola.
The Hassan Oktay-led charges managed to beat the visiting side with a 2-0 win, which brought them to within touching distance of the competition's next phase.
Gor Mahia's goals were scored late on, with Tuyisenge once again proving an important figure for K’Ogalo, getting himself on the scoresheet. Francis Kahata scored the opener in the 84th minute before the Rwandan striker added another almost at the death.
Kahata scored the opener against Hussein Dey.
A 1-0 defeat away to Hussein Dey in Algeria and a consequent 0-4 thumping by Zamalek complicated the Green Army's chances of progressing to the quarters of the continent's second-tier competition. That meant they had to win their last match at home against Petro Atletico.
In front of an almost packed Kasarani Stadium, Gor Mahia was shocked in the 36th when midfielder Ernest Wendo was sent off for a poor challenge on his opponent when the score was still tied at 0-0.
The hosts won a penalty in the 57th minute, though, and Tuyisenge rose to the challenge and made a successful conversion. However, Shafik Batambuze was also shown a red card in the 75th minute to complicate Gor Mahia’s task further.
Tuyisenge scored the penalty against Petro Atletico.
Francis Kahata had to track back and cover the space behind him before Geoffrey Ochieng was introduced to help in the defensive duties later on.
They held onto their slim lead, which ensured they qualified for the quarter-finals at the expense of Petro Atletico. Coach Oktay was also sent off during the closing stages for his incessant touchline complaints to the match commissioner.
He, alongside Tuyisenge, Wendo, Batambuze, and an injured Boniface Oluoch will miss the first leg of the home quarter-final against Renaissance Sportive de Berkane on Sunday, April 7.