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'
|Zidane shoud give James more respect - Asprilla|
|Solo suspended from USA women´s team for six months|
|Guardiola understands fans unhappiness over Hart situation|
|Burnley and Middlesbrough sent packing from League Cup|
|Coleman baffled by Ramsey´s treatment at Arsenal|
|Six of the best for Gladbach as Rostov rout Ajax|
|Leicester face Chelsea, Northampton host United in League Cup third round|
|Cillessen set to fly out to Barca to complete move|
|Guardiola hails ´legend´ Hart as Bravo wait in the wings|
|Emotional Hart edges towards City exit|
|Manchester City 1 Steaua Bucharest 0 (6-0 agg): City ease through amid Hart-felt goodbyes|
|Ronaldo working hard for Madrid return|
|Pique warns of European Super League dangers|
|AFC Champions League: Damjanovic inspires Seoul, Wanderley puts Al Nasr in charge|
|Rauball re-elected as German league president|
|Cillessen returns for Ajax despite Barcelona talk|
|Surgery for Pereira after De Rossi horror challenge|
|Hart set for City farewell against Steaua|
|CAF Champions League Review: Wydad draw at ZESCO to earn top spot|
|Retiring Keane in Republic of Ireland squad for final time|
|Sion in talks to sign Liverpool outcast Balotelli, claims club president|
|Athletic´s Laporte not distracted by Barcelona visit|
|Keane announces international retirement|
|Clarke named FA chairman|
|Neuer: Schweinsteiger remains one of world´s best|
|Bielsa would call me before coming to Marseille - Passi|
|Watford bring in Janmaat from Newcastle|
|FIFA opens adjudicatory proceedings against disgraced African football officials|
|European Super League could cause ´war´|
|Sampdoria pounce for Praet|
|Zaza agent confirms Napoli talks but rules out loan move|
|No Grigg in Northern Ireland´s World Cup qualifying squad|
|Cahill reflects on ´amazing´ Melbourne City debut|
|Europa League must take priority, Recoba tells Inter|
|Saint-Etienne swoop for Saivet and Veretout|
|Ronaldo: Pepe was the best player at the Euros, not Griezmann|
|Schweinsteiger: Manchester United my last club in Europe|
|Dante sees Nice as a positive move|
|Pique: Barcelona by far the best in Spain|
|Pique backs Stones for success under Pep|
|Coleman dismisses Premier League talk|
|Spurs want Calhanoglu, claims agent|
|Bony an ´option´ for Bilic|
|Leverkusen cannot challenge Bayern, says Ballack|
|Pallotta blasts ´disgusting´ referee after Roma defeat|
|Badstuber taking his time after injury nightmare|
|Conte: Terry return between him and Allardyce|
|We beat Bayern to Dembele - Watzke|
|Wanderers bring back Bulut|
|Moyes rules out Kone exit|
|CONCACAF Champions League Review: Whitecaps, Pachuca win big|
|Bale: I´ll never forget this year|
|Griezmann: I deserve Best Player in Europe Award|
|No surgery for Ayew as West Ham target December return|
|Villarreal did all they could to make it through - Escriba|
|Spalletti rues lack of Roma discipline|
|Conte: Chelsea must learn to kill matches|
|Watford and West Brom crash out of League Cup|
|My longest 90 minutes as a coach - Rodgers|
|AFC Champions League: Goalless draws leave quarter-finals on a knife edge|
|Klopp hopeful over Can injury|
|Champions League play-offs: Nine-man Roma crash out as Monaco edge Villarreal|
|Henderson hails ´outstanding´ Mane after Burton thrashing|
|Chelsea 3 Bristol Rovers 2: Conte´s side survive scare thanks to Batshuayi double|
|Hapoel Be´er Sheva 2 Celtic 0 (4-5 agg): Visitors survive Israeli scare|
|Burton Albion 0 Liverpool 5: Sturridge at the double in Reds rout|
|Leverkusen sign Austria star Dragovic|
|Sakho in the clear as WADA opt against appeal|
|Enyimba 3 Mamelodi Sundowns 1: Udoh brace secures CAF Champions League win|
|Pulisic and Ramos on target as Dortmund wrap up Bundesliga preparations|
|Calleri hoping for Tevez advice|
|Defour hoping for Belgium recall|
|Alaba warns against complacency as Bayern begin Bundesliga defence|
|Bravo arrives in Manchester ahead of City move|
|Dyche backs Gray after striker´s apology for homophobic tweets|
|Gray charged by FA over homophobic tweets|
|Pique: Olympic gold proves Neymar is one of world´s best|
|Marin makes Olympiacos move|
|Zidane arrival the catalyst for one of my best seasons - Ronaldo|
|Moyes ´worried´ about Mannone elbow injury|
|Sidibe rejected Arsenal over playing-time fears|
|Guardiola: Toure could feature against Steaua|
|Hernandez out for two weeks after falling down stairs|
|Bravo nearing City move, admits Guardiola|
|Ballack impressed by Dortmund signings but still backing Bayern|
|Lucescu questions De Boer tactics|
|Milan reject Chelsea bid for Romagnoli|
|Dortmund know how to treat Gotze - Ballack|
|Shevchenko: Bacca must improve consistency|
|´If you heed 100 idiots you will go crazy´ - Bauza on Messi return|
|Valdano relieved over Messi U-turn|
|Nordfeldt in line for loan move after signing fresh Swans deal|
|Dante joins Nice from Wolfsburg|
|De Boer expects fierce fight for Barca number-one spot|
|Newell´s confident over Messi return|
|Stoke confirm Jones interest|
|MLS ´attractive´ to Rooney - Timbers owner|
|Burke re-signs with West Ham|
|Sassuolo rejected Balotelli - CEO|
|Valencia coach Ayestaran rules out Mustafi sale|
|Allardyce plans Guardiola talks over Hart|
|Cahill warns rivals over City attack|
|Allardyce open to Terry England return|
|Drogba dismisses Villa rumours|
|Tuchel pleased despite Dortmund wastefulness|