David Kily's stunning stoppage-time strike sent co-hosts Equatorial Guinea into the quarter-finals of the African Nations Cup and left Senegal facing up to the ignominy of elimination after just two games.
Kily struck a long-range effort deep into time added on after Moussa Sow's 89th-minute strike for Senegal had cancelled out Randy's opener after 62 minutes.
The winning goal sparked emotional scenes at the final whistle, with the result far beyond the expectations of the players or their fans at the Estadio de Bata.
Laurence Doe saw red for Equatorial Guinea in the seventh minute of stoppage time after picking up a second booking for apparent time-wasting, but he will only miss his side's final group game, now little more than a dead rubber.
Despite a miserable recent history at this tournament, Senegal came into this year's edition as one of the favourites for the title, but a second defeat in as many games has delivered a terminal blow to their chances, with Amara Traore's men now unable to qualify from Group A in their final game.
Victory for Equatorial Guinea came hot on the heels of their 1-0 win over Libya and leaves them leading the way in the group ahead of their final outing against Zambia, who sit second on four points after a 2-2 draw with Libya earlier on Wednesday.
The match was played in tricky conditions after the pitch at the Estadio de Bata was saturated earlier today in a heavy downpour ahead of the Libya-Zambia match.
The weather forced the kick off the early to be pushed back by 75 minutes, and the same delay was applied to the evening's late kick off, when conditions were much drier but still problematic enough to prevent a free-flowing encounter.
The conditions no doubt played a part in a forgettable opening 45 minutes which produced little in the way of presentable chances, but the game opened up after the break, with Guinea's Thierry Fidjeu and Senegal's Papiss Cisse trading shots in the minute after the restart.
Narcisse Ekanga headed over for the co-hosts on 58 minutes as the game continued to open up, and the first goal duly arrived after 62 minutes.
Kily was the architect, his precise cross from the right met by Randy with a firm header from six yards.
Mamadou Niang and Sow went close to pulling Senegal level inside the final 15 minutes, but they had to wait until the 89th minute to get back on level terms, Niang teeing up Sow, who fired home emphatically from close range to seemingly keep Senegal's hopes in the tournament alive.
But there was sting in the tail to come, and it arrived four minutes into stoppage time when Javier Balboa picked out Kily from the left channel, and the defender unleashed an unstoppable drive from 25 yards to sent his side through
to the last eight in the most dramatic of circumstances.
There was still time for Doe to see red for Guinea late on, but even that could
not dampen the scenes of jubilation both on the pitch and in the stands.