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'
|Real Madrid make €1m pledge to help refugees|
|Ings: I can learn from ´fantastic´ Sturridge|
|Ozil: Scotland won´t stop us|
|Portugal will be better than France - Santos|
|Kruse: I am 100 per cent fit|
|FFA expect Tajikistan match to go ahead despite Dushanbe violence|
|Mexico 3 Trinidad and Tobago 3: Herrera the hero for Ferretti´s men|
|Panama 0 Uruguay 1: Stuani´s late header clinches win|
|CONCACAF World Cup Qualifying Review: Jamaica stunned, Canada win|
|Argentina 7 Bolivia 0: Aguero, Messi star in rout|
|Canada 3 Belize 0: Hosts dominate in Toronto|
|Chelsea ´warehousing´ players - PFA chief|
|United States 2 Peru 1: Altidore inspires hosts´ comeback|
|Argentina 7-0 Bolivia: Aguero, Messi & Lavezzi net doubles in rout|
|Del Bosque unmoved by calls for two strikers|
|Deschamps praise for beautiful France|
|Fekir ruptures knee ligaments|
|Italy v Bulgaria: Conte warns against complacency|
|Euro 2016 Qualifiers Review: Germany top Group D, Northern Ireland edge closer|
|Low: Three points most important|
|Northern Ireland on the verge of a ´magnificent achievement´ - O´Neill|
|Scotland need something against Germany - Strachan|
|Portugal 0 France 1: Late Valbuena set-piece clinches deserved win|
|Faroe Islands 1 Northern Ireland 3: O´Neill´s men edge closer|
|Germany 3 Poland 1: Gotze sends world champions top|
|Gibraltar 0 Republic of Ireland 4: Irish hopes reignited|
|Djibouti 0 Togo 2: Saintfiet´s side make it two wins from two|
|Cyprus v Belgium: Benteke boost for Wilmots´ men|
|Roma youngster faces lengthy lay-off|
|United hit back at Perez barb over De Gea saga|
|Georgia 1 Scotland 0: Strachan´s men succumb to Tbilisi hoodoo|
|Hodgson prepared to blood new players|
|Porto invite Euro elite to help raise millions for migrants|
|Dortmund legend Dede backs Tuchel to succeed|
|Robben out for four weeks|
|Turkey v Netherlands: Terim expecting hostile atmosphere for crunch clash|
|Portugal 0-1 France: Valbuena strikes late to sink Ronaldo & Co|
|Wales v Israel: Euro 2016 beckons for Coleman´s history boys|
|Gala: No extra payment for Grosskreutz|
|Increase Bundesliga´s TV rights or be left behind - Rummenigge|
|Kane: I´m no flash in the pan|
|Perez: United showed inexperience in De Gea saga|
|Milligan: Socceroos wary of Tajikistan|
|Conte wants more players like Pelle|
|OFC World Cup Qualifying Review: Samoa to meet Tahiti in next round|
|Krychowiak stayed at Sevilla because of Emery|
|I never considered Bayern exit - Gotze|
|Balotelli ´not in good condition´, Milan must improve - Mihajlovic|
|Robben slams ´stupid´ Martins Indi|
|Robben laments injury blow|
|Euro 2016 Qualifiers Review: Bale edges Wales closer, Iceland dent Netherlands´ qualification hopes|
|De Bruyne relieved to ´boss´ Bosnia-Herzegovina|
|Blind furious after nightmare debut|
|Coleman sees shades of Charles in Bale winner|
|Conte only concerned about Italy winning|
|Mauritania v South Africa: SAFA to investigate Masilela no-show|
|AFC World Cup Qualifying Review: Qatar hit 15 in Bhutan rout|
|Belgium 3 Bosnia-Herzegovina 1: De Bruyne shines in straightforward victory|
|Cyprus 0 Wales 1: Bale winner takes Wales one step closer|
|Netherlands 0 Iceland 1: Sigurdsson winner caps difficult first game for Blind|
|Italy 1 Malta 0: Pelle spares wasteful Azzurri|
|Balotelli stars in Milan friendly win|
|Bhutan thrashed 15-0 by Qatar in qualifier|
|Rwanda v Ghana: Gyan doubt gives hosts hope|
|Tanzania v Nigeria: Enyeama out of AFCON qualifier|
|Valdes and Berahino included in Premier League squads|
|Costa Rica v Brazil: Dunga´s men return after Copa disappointment|
|Spain v Slovakia: Azpilicueta eyeing important revenge|
|Adebayor left out of Tottenham squad list for league and Europe|
|San Marino v England: Place in history books beckons for Rooney|
|Germany can cope with Reus absence - Low|
|Bayern offer aid to refugees in ´training camp´|
|BREAKING NEWS: Welbeck ruled out for months after knee surgery|
|South Korea 8 Laos 0: Son leads the way in rout|
|Australia 5 Bangladesh 0: Socceroos surge to emphatic win|
|Japan 3 Cambodia 0: Hosts pick up first qualifying win|
|Rudiger aiming to nail down Euros spot after Roma move|
|Melo happy to join Inter at last|
|Hernandez thanks Ferguson after United departure|
|Chung: AFC has compromised FIFA election|
|Wales the new best of British|
|Reus out of Germany qualifiers|
|Chile v Paraguay: Vidal missing for Copa champions|
|Ghedin: Anything is possible for Malta|
|Pogba will be worth €100m - Marotta|
|England can win Euro 2016 - Hodgson tells players|
|Conte unsure over Balotelli future|
|Argentina - Bolivia Preview: Mascherano backs 'very special' Messi|
|Portugal - France Preview: Deschamps aiming to correct mistakes|