Zenit St Petersburg lost 4-1 at Austria Vienna but reached the UEFA Champions League knockout phase due to Porto's loss at Atletico Madrid.
The Russian side required victory to progress from Group G without relying on the outcome in the Spanish capital and Aleksandr Kerzhakov put them on course to do just that with the opener in the 35th minute.
However, Vienna scored three goals – two courtesy of Philipp Hosiner – within seven minutes either side of the break to leave Zenit facing an anxious wait before Roman Kienast added a fourth late on.
Porto were unable to recover a first-half deficit, resigning them to UEFA Europa League football and sending Zenit through to the Champions League round of 16 with only six points from six games.
Vienna, who were guaranteed to finish bottom before kick-off, celebrated their first win in Europe's elite competition, with Tomas Jun also on target.
The home side were without defender Lukas Rotpuller and midfielder Bernhard Luxbacher due to injury, while playmaker Danny missed out for Zenit.
That did not prevent the Russian heavyweights creating chances in an opening half hour they dominated.
Within 180 seconds, Hulk fired over the crossbar following a neat passing move. Domenico Criscito was then close to connecting with a Viktor Fayzulin cross, before Hulk created space for himself with some delightful footwork only to see his shot from the edge of the box blocked by Kaja Rogulj.
Zenit eventually broke the deadlock in the 35th minute. Kerzhakov's clever movement coupled with defender Manuel Ortlechner's untimely slip allowed the former to race on to Hulk's reverse throughball. Kerzhakov took it round goalkeeper Heinz Lindner and slotted home into the empty net.
Out of nothing, however, Vienna equalised on the stroke of half-time. Hosiner robbed Zenit of possession, played a superb one-two with Marko Stankovic and slotted the ball across goalkeeper Yuri Lodygin and into the bottom corner.
Within six minutes of the restart, Vienna were 3-1 up. First, following a very poor goal-kick from Lodygin, Markus Suttner controlled the ball sublimely and crossed to give Jun a tap-in.
Then Florian Mader's long-range strike was parried by Lodygin straight into the path of Hosiner, who thumped the ball home to complete his brace.
Zenit tried to respond as Konstantin Zyryanov went close from distance, Hulk forced Lindner into a smart save and Axel Witsel saw his powerful strike go narrowly over the crossbar.
But Vienna completed a 4-1 success in injury time, when the brilliant Hosiner crossed for substitute Kienast to fire home.
|16||P. Hosiner||44' 51'|
|Coach: N. Bjelica|
for T. Murg 60'
for M. Stankovic 68'
for T. Jun 83'
|Geromel replaces Caio in Brazil squad|
|Mustafi: Ozil convinced me to join Arsenal|
|Pardew confirms ´one or two´ more signings|
|MLS Review: Kaka brace denies NYC top spot, Timbers beat Sounders|
|Mihajlovic: I won´t waste anymore breath on Maksimovic|
|Okon named Central Coast Mariners coach|
|´Special´ Rashford will get chance - Rooney|
|Injury forces Schurrle out of Germany squad|
|Burke snubs Premier League interest to join RB Leipzig|
|Guardiola: Nasri has a future at City, if he wants it|
|Klopp confident ´all will be good´ with Sturridge|
|Emery confident PSG will bounce back|
|Athletic may strengthen squad - Valverde|
|Fabregas dismisses exit rumours, committed to Conte and Chelsea|
|De Boer encouraged as Inter´s wait continues|
|Barca ´strengthened´ by Luis Enrique´s 100th win|
|Fekir to undergo knee operation|
|Monaco 3 Paris Saint-Germain 1: Ligue 1 champions suffer early loss|
|Aguero facing possible Manchester derby ban|
|Athletic Bilbao 0 Barcelona 1: Rakitic strike extends Barca´s strong start|
|West Ham´s Antonio handed first England call-up|
|Guardiola ´so optimistic´ after Man City´s perfect start|
|Inter 1 Palermo 1: Icardi gets De Boer´s men off the mark|
|Credit Guardiola for boost in form, says Sterling|
|Manchester City 3 West Ham 1: Hosts stay perfect under Guardiola|
|Cavani won´t return to Napoli - De Laurentiis|
|Pulis puts 48-hour deadline on Berahino future|
|Zaza awaits ´new adventure´ at West Ham|
|Karanka open to transfer ´surprises´ after strong Middlesbrough start|
|Dost completes Sporting move|
|Allardyce wanted N´Zonzi for England|
|World Cup could be expanded - Infantino|
|West Brom 0 Middlesbrough 0: Booed Berahino benched for dour draw|
|Gyan´s ´destiny´ in England, Sunderland return an option|
|Zidane wanted Pogba and Madrid are weaker without him - Raiola|
|Juventus end Matuidi pursuit|
|´He´s freaking amazing!´ - Balogun hails Dortmund´s Dembele|
|Thohir thrilled as Inter confirm Joao Mario signing|
|Fabinho expects Monaco stay despite Manchester United links|
|Infantino has Blatter wine cellar removed as part of FIFA reform commitment|
|West Ham seal Zaza loan|
|Joao Mario posts heartfelt thanks to Sporting after record-breaking Inter move|
|Aguero: I´m not competing with Ibrahimovic|
|Mihajlovic: Maksimovic is dead to me|
|Risdon replaces Wright for Socceroos|
|MLS Review: DC United in goal-fest, Impact stun Toronto|
|Schmeichel to undergo surgery|
|Milik revels in ´dream´ brace as he ignores Higuain shadow|
|Rossi to join Celta Vigo|
|Ayestaran: Barcelona target Alcacer unable to compete|
|Simeone: Winless Atletico must remain calm|
|Griezmann: Atletico must improve or face relegation fight|
|Sterling ´feels the love´ at City - Guardiola|
|Stones glad he did not end up at Chelsea|
|James impact earns Zidane´s praise|
|Montella bemoans AC Milan´s indiscipline|
|Leganes 0 Atletico Madrid 0: Returning Griezmann fails to inspire turgid visitors|
|Everton fan passes away after taking ill at Goodison Park|
|Napoli 4 AC Milan 2: Milik and Callejon at the double against Montella´s nine men|
|Aubameyang eyes Lewandowski duel|
|International break timely for Hull recruitment - Phelan|
|Real Madrid 2 Celta Vigo 1: Late Kroos strike saves hosts|
|Mourinho worry over Fellaini back injury|
|Allegri marvels at ´exceptional´ Khedira|
|Mourinho promises more chances for matchwinner Rashford|
|We didn´t play our best - Tuchel|
|Rashford: Setbacks part of football|
|No hiding, Arsenal want the title - Cech|
|Hull City 0 Manchester United 1: Rashford´s late show thwarts Phelan´s battlers|
|Bamford nearing Burnley loan|
|Leicester proved they are still one of the best - Guidolin|
|Pardew stands by unsettled Zaha|
|Koeman sympathises with Hughes´ frustration|
|Lazio 0 Juventus 1: Khedira nets again as Allegri´s men prevail|
|Moyes defends Pickford after late howler|
|Conte: Hazard can still improve|
|Hughes bemoans confusion over new refereeing directives|
|Howe regrets Bournemouth caution|
|Home draw leaves Puel frustrated|
|´A goalscorer never forgets´ - Ranieri thrilled as Vardy returns to form|
|Derby sign Vydra from Watford|
|Wenger flags imminent arrival of Mustafi, Perez|
|Crystal Palace 1 Bournemouth 1: Dann late show denies Cherries|
|Southampton 1 Sunderland 1: Pickford howler costs Black Cats two points|
|Chelsea 3 Burnley 0: Hazard shines in dominant win|
|Everton 1 Stoke City 0: Joy for Koeman at Given´s expense|
|Leicester City 2 Swansea City 1: Vardy and Morgan give champions first win|
|Watford 1 Arsenal 3: Sanchez inspires Gunners´ first win of the season|
|Borussia Dortmund 2 Mainz 1: Aubameyang double seals winning start for Tuchel´s men|
|Klopp defends benching Sturridge|
|Pochettino satisfied with Liverpool draw|
|Milner: Liverpool didn´t do enough after leading|
|Lahm ready to run the hard yards for Ancelotti|
|United have the fear factor back - Shaw|
|Tottenham 1 Liverpool 1: Rose denies Klopp´s men victory|
|Donnarumma called up as Ventura turns to youth|
|´Unique, exceptional work´ - Luis Enrique hails departed Bravo|
|Luis Enrique won´t rule out Munir exit|
|Portugal´s powerhouses divide to conquer once more|
|Ter Stegen, Mascherano in Barcelona squad for Athletic clash|
|Guardiola passion infectious, says Bravo|
|Palermo confident of Balotelli deal|
|Bayern are free of Guardiola´s chains, says Scholl|
|Ronaldo: I´ll be back in no time|
|Colombia name squad for Venezuela, Brazil qualifiers|
|Pellegrini becomes Hebei China Fortune coach|
|Klopp has ´no doubt´ over Henderson´s Liverpool future|
|Lallana understands questions over Liverpool displays|
|Real Salt Lake 2 Colorado Rapids 1: Movsisyan at the double|
|Wenger insists Perez and Mustafi are not panic buys|
|Ranieri confident of Vardy resurgence|
|Atletico send Jota on loan to Porto|
|Mourinho not rushing ´super´ Mkhitaryan|
|Bayern to meet Augsburg, Dortmund face Union in DFB-Pokal second round|