Egypt beat Ivory Coast 5-4 on penalties to reach the quarter-finals at the Africa Cup of Nations in Cameroon following a 0-0 draw.
The North Africans got the upper hand in the shoot-out when substitute keeper Gabaski saved Eric Bailly's effort in the third round of spot-kicks.
And Pharaohs captain Mohamed Salah netted the decisive penalty to send the record seven-time champions through.
Egypt will face Morocco in the last eight in Yaounde on Sunday (16:00 GMT).
The finale was somewhat harsh on Manchester United defender Bailly, who had performed superbly at the back while sporting a rugby scrum cap on his return from a head injury.
Yet he took a short run-up for his penalty and placed his effort too close to Gabaski, who dived to his right and stuck out his left hand to push the ball onto the bar.
The Zamalek keeper had come on right at the end of the second half after Mohamed El Shenawy picked up a leg injury, and may well start against Morocco depending on the extend of the injury suffered by Egypt's number one.Relive Egypt's penalty win over Ivory CoastAfrica Cup of Nations fixtures
Pharaohs receive local backing
It may have ended goalless after 120 minutes but the meeting between two of the continent's heavyweights provided plenty of openings despite the spoor state of the pitch in Douala.
Two-time champions Ivory Coast had knocked out defending champions Algeria en route to topping their group, but Egypt had finished second in theirs after losing their opening game against Nigeria.
Cameroonians threw their support behind the Pharaohs, and the appearance of Liverpool forward Salah on the big screen in the stadium during the Egyptian national anthem was met with a loud roar.
The North Africans had the better of the first half, with Omar Marmoush rattling the Ivory Coast crossbar and Salah having two attempts tipped over by Badra Ali Sangare.
The Elephants grew into the contest and Ibrahim Sangare saw an acrobatic volley pushed away by El Shenawy.
Salah keeps nerve
Early in the second period Egypt's Amr El Soleya blazed over when well placed inside the area while substitute Trezeguet dragged a shot across goal and wide.
El Shenawy pulled off good stops to keep out a header from Sebastien Haller and a shot from Wilfried Zaha but was then forced off.
The North Africans started the first period of extra time well, as Mohamed Sherif headed over and Sangare punched away a long-range shot by Zizo, while Gabaski denied midfielder Sangare just before the break.
Trezeguet had a late chance to win it for Egypt, but Carlos Quieroz's side progressed after Gabaski made the crucial save and Salah kept his nerve.
Salah's influence had waned as the game wore on but had the final say from 12 yards, and he could yet lead Egypt to their first continental crown since 2010.
Two games moved away from Douala
The surface in the Japoma Stadium had been criticised during the group stage, and the surface cut up during Tuesday's last-16 clash.
During the game the Confederation of African Football announced that two upcoming matches will be moved away from Douala.
Senegal's quarter-final against Mali or Equatorial Guinea on Sunday and the semi-final which was due to be held in the port city have been switched to Yaounde.
Hosts Cameroon take on debutants The Gambia in the last eight at the Japoma Stadium on Saturday, and the Indomitable Lions will need to navigate both a tricky pitch and giant-killing opposition to continue their bid for a sixth Nations Cup title.
Formation 4-3-323Sangaré17Aurier21BaillyBooked at 9mins14DeliBooked at 112mins3Konan18Sangaré4SeriSubstituted forBogaat 72'minutes8KessiéSubstituted forDiéat 30'minutes15GradelSubstituted forZahaat 71'minutesBooked at 118mins22HallerSubstituted forCornetat 105'minutes19Pépé
Formation 4-3-31GomaaSubstituted forAbou Gabal Aliat 88'minutes3Abdel Wahed6Hegazy2Abdelmonem Elsayed Mohamed Ahmed13Mohamed17Elneny4El Soleya5Abdul FattahSubstituted forSayedat 84'minutesBooked at 90mins10Salah14Ahmed AbdallahSubstituted forMohamed Ragaei Bakrat 90'minutes22MarmoushSubstituted forTrézéguetat 71'minutes
Substitutes7Trézéguet8Abdelghany9Mohamed Ragaei Bakr11Sobhi12Ashraf16Abou Gabal Ali18Ahmed Abdelmonem19Bekhit20Eldin Mahmoud Ibrahim21Sayed23Daader28Mehany
Referee:Jean Jacques Ndala Ngambo
Match ends, Côte d'Ivoire 0(4), Egypt 0(5).
Penalty Shootout ends, Côte d'Ivoire 0(4), Egypt 0(5).
Goal! Côte d'Ivoire 0(4), Egypt 0(5). Mohamed Salah (Egypt) converts the penalty with a left footed shot to the bottom right corner.
Goal! Côte d'Ivoire 0(4), Egypt 0(4). Wilfried Zaha (Côte d'Ivoire) converts the penalty with a right footed shot to the bottom left corner.
Goal! Côte d'Ivoire 0(3), Egypt 0(4). Mohamed Abdelmonem (Egypt) converts the penalty with a right footed shot to the top left corner.
Goal! Côte d'Ivoire 0(3), Egypt 0(3). Maxwel Cornet (Côte d'Ivoire) converts the penalty with a left footed shot to the bottom left corner.
Goal! Côte d'Ivoire 0(2), Egypt 0(3). Omar Kamal (Egypt) converts the penalty with a right footed shot to the centre of the goal.
Penalty saved! Eric Bailly (Côte d'Ivoire) fails to capitalise on this great opportunity, right footed shot saved in the bottom left corner.
Goal! Côte d'Ivoire 0(2), Egypt 0(2). Amr El Soleya (Egypt) converts the penalty with a right footed shot to the bottom left corner.
Goal! Côte d'Ivoire 0(2), Egypt 0(1). Ibrahim Sangaré (Côte d'Ivoire) converts the penalty with a right footed shot to the bottom right corner.
Goal! Côte d'Ivoire 0(1), Egypt 0(1). Zizo (Egypt) converts the penalty with a right footed shot to the top left corner.
Goal! Côte d'Ivoire 0(1), Egypt 0. Nicolas Pépé (Côte d'Ivoire) converts the penalty with a left footed shot to the bottom right corner.
Penalty Shootout begins Côte d'Ivoire 0, Egypt 0.
Second Half Extra Time ends, Côte d'Ivoire 0, Egypt 0.
Attempt saved. Trézéguet (Egypt) left footed shot from the centre of the box is saved in the top centre of the goal. Assisted by Mohamed Salah.
Wilfried Zaha (Côte d'Ivoire) is shown the yellow card.
Foul by Wilfried Zaha (Côte d'Ivoire).
Trézéguet (Egypt) wins a free kick in the defensive half.
Corner, Egypt. Conceded by Serge Aurier.
Attempt blocked. Trézéguet (Egypt) left footed shot from the left side of the box is blocked. Assisted by Mohamed Salah.