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. Stanković 68'
for T. Jun 83'
|Parma captain Lucarelli welcomes FIGC reforms|
|Di Francesco ignoring Milan rumours|
|Melbourne Victory 2 Central Coast Mariners 1: Finkler leads fightback|
|Bale would be ´perfect´ for United - Scholes|
|Badstuber and Bellarabi out of Georgia clash|
|Rooney KOs boxing celebration|
|Allen thrilled with Welsh ´hunger´|
|Kovacic to miss Euro 2016 qualifier|
|Costa Rica 0 Paraguay 0: Dour draw marks Diaz debut|
|Reid ruled out of South Korea friendly|
|Deschamps talks up France despite defeat|
|Rooney chasing England goalscoring record|
|Brazil ´superior´ admit French veterans|
|Reeves sidelined for Finland clash|
|Confidence critical for rampaging Brazil - Dunga|
|France 1 Brazil 3: Dunga´s men maintain winning run|
|Chile 0 Iran 2: Nekounam and Amiri down Copa America hosts|
|Premier League to share over £1bn from record TV deal|
|Morocco v Uruguay: Last chance to impress Tabarez for Copa champions|
|Iran 2-0 Chile: Nekounam and Amiri down Copa America hosts|
|Ivanovic braced for Ronaldo test|
|Bahrain 0 Colombia 6: Falcao stars in comfortable victory|
|Jones to Bournemouth leads loan deadline day moves in Championship|
|Bahrain 0-6 Colombia: Falcao stars in resounding victory|
|Malmo fined for poor pitch by UEFA|
|League Two Preview: Hartlepool aim to continue great escape, leaders Burton host Stevenage|
|France 1-3 Brazil: Neymar on target as Selecao triumph in Paris|
|Bulgaria v Italy: Verratti vows to be Azzurri´s midfield general|
|Kane primed for full England debut|
|Kone receives positive news over knee injury|
|Terry pens new Chelsea deal|
|PSG tie down Marquinhos|
|De Gea stamp was accidental - Skrtel|
|Villa hopeful over Xavi reunion|
|El Salvador v Argentina: Messi set for Roca reunion|
|Ghana v Senegal: Grant´s side looking to rebuild after AFCON disappointment|
|Ferdinand to serve extended touchline ban|
|League One Preview: Duo aiming to inspire Notts County revival, Alexander back at Preston|
|Hodgson keeps an eye on Sterling and Milner|
|Filipe Luis cools talk of Atleti return|
|West Brom to wear retro kit for Leicester clash|
|Netherlands v Turkey: Sneijder unconcerned by key absentees|
|Del Bosque wary of Ukraine threat|
|Israel v Wales: Pivotal fixture for both sides in chase for Euro dream|
|Bosnich backs Villa to beat drop|
|Walcott denies Wenger ´bust-up´|
|Hart: Aguero more difficult to face than Messi|
|Williams: I can´t see myself playing for anyone else|
|Coutinho eager to add more goals to his game|
|Khedira confirms Real exit|
|Messi attends NBA match with Argentina squad|
|United will qualify for Champions League - Bosnich|
|Mexico v Ecuador: Hernandez desperate to play|
|Podolski plays down Germany cameo|
|Bendtner: I could have scored four|
|Leverock family adds to World Cup exploits for Bermuda|
|Pele: ´Impossible´ for Neymar to replace me|
|MLS Preview: New England hoping to end drought|
|A-League Preview: Phoenix without stars for Sydney showdown|
|Klinsmann laments late collapse|
|Premier League clubs post first pre-tax profit for 15 years|
|Vokes relishing chance to link up with Bale|
|Dunga encourages Brazil to entertain|
|Dyke: FA to discuss Hodgson extension|
|Janko eyes history with Austria|
|Wilson urges Begovic to stay put|
|Strachan: Scotland have work to do|
|Sky´s the limit for Australia - Postecoglou|
|Low unhappy with below-par Germany|
|Scotland 1 Northern Ireland 0: Berra´s header settles dour contest|
|Germany 2 Australia 2: Substitute Podolski salvages draw|
|Denmark 3 United States 2: Bendtner hat-trick rescues Danes|
|Scotland 1-0 Northern Ireland: Berra the unlikely hero for hosts|
|Gobbi: Players will ´pay the price´ to keep Parma afloat|
|Rose withdraws from England squad|
|Germany 2-2 Australia: Podolski rescues draw for World champions|
|Denmark 3-2 USA: Bendtner hat-trick wins it for the Danes|
|Nigeria 0 Uganda 1: Late winner sours Enyeama landmark|
|Swaziland 1 South Africa 3: Bafana Bafana back to winning ways|
|Camp Nou to host Copa del Rey final|
|Labadie charged with violent conduct after biting claims|
|Bender keen to rekindle Bayern rivalry|
|Swansea eager to tie down Taylor|
|Varane learning from Real troubles|
|Forster ruled out for rest of season|
|Inter full-back Dodo has successful surgery|
|Verratti focused on future at PSG|
|Minnesota awarded MLS expansion team|
|Ibrahimovic slams ´b******t´ PSG exit rumours|
|Gibson withdraws from Ireland squad|
|Ozil convinced he can win Ballon d’Or|
|Costa: I take a beating from Premier League defenders|
|Canada v Guatemala: Floro seeks to develop winning mentality|
|Vermaelen returns to Barcelona training|
|Euro 2016 Qualifying Preview: Spain face big Ukraine test, Germany visit Georgia|
|Spain v Ukraine: Morata set for first competitive start|
|England v Lithuania: Hart urges Kane not to leave U21s behind|
|Monchengladbach snap up Hannover skipper Stindl|
|Khedira gives strong hint of Real exit|
|Skrtel banned for three matches|
|Brisbane Roar 1 Western Sydney Wanderers 4: Champions´ title defence in tatters|
|Sampdoria swoop for Ajax captain Moisander|
|Barnes: Sterling not ready for big-money move|
|Ferdinand: Ramsey appointment a gamble|
|Ideye hopeful of facing QPR|
|Lampard eyes MLS showdown with Gerrard|
|Ronaldo could face suspension over Clasico celebration|
|Hodgson expects more withdrawals|
|Schalke fans overwhelm Farfan after injury lay-off|
|Swedish third-tier club Dalkurd avoid Germanwings flight|
|Japan v Tunisia: Halilhodzic takes charge of hosts for first time|
|Schweinsteiger brushes aside captaincy pressure|
|Barzagli supports Conte call-ups|
|South Korea v Uzbekistan: Stielike searching for improvement|
|France wary of more balanced Brazil|