Mohamed Bayo headed a 98th-minute winner as Guinea reached the quarter-finals of the Africa Cup of Nations with victory over 10-man Equatorial Guinea, who had earlier missed a penalty.
Equatorial Guinea midfielder Federico Bikoro was dismissed 10 minutes after the break for catching Bayo in the ribs with his studs.
The National Thunder were awarded a spot-kick midway through the second half after Sekou Sylla caught Iban Salvador, but captain Emilio Nsue hit the base of the right-hand upright.
And, with the game set to head to extra time, striker Bayo stooped to guide Ibrahim Diakite’s cross from the right flank just inside the near post in the final minute of added time.
The West Africans have made the last eight for the first time since 2015 and next play in Abidjan on Friday, when they will face either Egypt or DR Congo, who meet later on Sunday (20:00 GMT).
Guinea had barely made their one-man advantage count in the final 35 minutes, although goalkeeper Jesus Owono was forced to tip a header from striker Serhou Guirassy over the bar in the closing stages.
Yet Bayo’s dramatic late goal broke the resistance of the Equatoguineans and gave the Syli National their first triumph in seven knock-out stage appearances at the finals.
The Le Havre striker’s header, clocked at 97 minutes and 38 seconds, is the latest winning goal in a knockout match in the history of the Africa Cup of Nations.
Equatorial Guinea had been the surprise package of the group stage, winning Group A ahead of Nigeria and hosts Ivory Coast as Nsue netted five goals to top the scoring charts.
In the first half, there was scant action in the final third, with Bayo sending an effort into the side-netting early on and Guinea team-mate Morgan Guilavogli firing over from long range.
Nsue blasted a volley over the bar from 12 yards two minutes after the restart, but the complexion of the game changed when Bikoro was shown a straight red after following through with a clearance in midfield and catching Bayo with some force.
Equatorial Guinea were handed a glorious chance to take the lead when the video assistant referee sent Omar Artan to his touchline screen, and the referee awarded a penalty, deciding Sylla had caught Iban Salvador on the back of the leg after the midfielder had controlled a pass.
But veteran striker Nsue, who plays in the third tier in Spain, could not add to his tally at the finals despite sending Guinea keeper Ibrahim Kone the wrong way.
Aside from substitute Guirassy’s header, a tame effort from right-back Diakite was all Guinea could muster before the board for eight minutes of added time went up and Bayo won it at the death.
Equatorial Guinea had reached at least the quarter-finals on their previous three appearances at Afcon, but Juan Micha’s side could not repeat that achievement as 34-year-old Nsue was left to rue his costly miss while Guinea celebrated at the final whistle.
The West Africans, managed by one-time Arsenal striker Kaba Diawara, had finished behind holders Senegal and Cameroon but progressed to the knockout stages as one of four best-ranked third-placed sides.