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'
|Mauri completes Milan move|
|City sign Turkey striker|
|Women´s World Cup final draws huge US TV ratings|
|My first Chelsea team better than current crop - Drogba|
|Bertrand set for lay-off after knee surgery|
|New five-year Juve deal for Marchisio|
|Allegri extends Juve contract|
|Koeman reiterates Alderweireld interest|
|Valencia bag Bakkali|
|New York City FC complete Pirlo capture|
|Panama v Haiti: Collat ready to challenge the best of CONCACAF|
|UEFA Champions League Preview: Harrison eyes TNS progression|
|FIFA sanctions Yemen for fielding ineligible player|
|Toulouse rubbish Ben Yedder exit reports|
|Mourinho ´knows what he´s doing´ with Falcao signing|
|Watford shell out club-record fee for Capoue|
|Braafheid signs Lazio extension|
|Nani finalises Fenerbahce move|
|Liverpool confirm O´Driscoll appointment|
|Liverpool have to start better - Lucas|
|USA simply too good - Sasaki|
|Portland Timbers 1 San Jose Earthquakes 0: Jewsbury wins it in stoppage time|
|No move yet for Van Persie|
|Lloyd wins Golden Ball, Silver Boot awards|
|Mascherano: I never grabbed Banega|
|Dunga requested Brazil not appeal Neymar´s suspension|
|United States 5 Japan 2: Lloyd stars with hat-trick|
|Fiorentina deny Inter criticism|
|Nani relishing Fenerbahce opportunity|
|Newcastle hold talks over Northampton youngster|
|Cuadrado´s agent plays down Chelsea exit rumours|
|Liverpool´s Alberto set for Deportivo loan|
|Leverkusen suffer surprise defeat, Stuttgart hit six|
|Inter ´dismayed´ at Fiorentina vice-president´s Salah Twitter outburst|
|Blaszczykowski ruled out of Dortmund´s Asia tour|
|Gerrard gets the beers in for LA Galaxy fans|
|De Gea coy over Real links|
|Former Brazil star Carlos handed Delhi reins|
|Ciftci will not push through Celtic switch – agent|
|In-demand Mitrovic considering Roma offer|
|Lehmann calls on Cech to ´get over´ Chelsea|
|Marlos double sinks Monaco|
|Mauritius 0 South Africa 2 (agg 0-5): Bafana set up Angola qualifier|
|Keane relishing Gerrard arrival|
|Palace confirm Cabaye interest|
|Hamburg bring in Spahic after head-butt ban|
|Blatter hits out at France and Germany over World Cup votes|
|Sanchez: World Cup exit spurred Chile to Copa glory|
|Jojic makes Cologne switch, Santana move falls through|
|Carrillo keen to get going at Monaco|
|Micronesia thrashed 38-0 as Fiji triumph in Olympic qualifier|
|Schalke stunned by ´machine´ Caicara|
|MLS Review: Keane shines at Gerrard´s Galaxy unveiling|
|Counter-attacking the key for Japan|
|Jimenez happy at Atletico|
|Gerrard predicts ´successful future´ with Galaxy|
|Iniesta can´t see Real selling Ramos|
|Keshi sacked as Nigeria coach|
|Three finals, three defeats for Messi, Mascherano|
|Nani close to Fenerbahce move|
|Sampaoli revels in ´unbelievable joy´|
|Bravo: Copa victory a dream|
|Martino: Argentina should have won|
|Chile 0 Argentina 0 (4-1 on penalties): Hosts end trophy drought|
|Germany 0 England 1 (after extra time): England make World Cup history|
|Kenya 0 Ethiopia 0 (agg 0-2): Hosts sent out of CHAN qualifiers after second penalty miss|
|Dortmund put 17 past Olympians, Bremen hand out thrashing|
|Dinamo Zagreb confirm arrests of coach and club president|
|I didn´t know who Wimbledon guest Klopp was - Brown|
|LeBron James backs Liverpool captain Henderson for FIFA 16 cover.|
|Ramos: I am not negotiating with anyone|
|Valencia complete Mina swoop|
|United States v Japan: US seek final redemption|
|Hanousek consigns Celtic to defeat|
|Roma confirm Dzeko interest|
|Arsenal forward Podolski completes Galatasaray switch|
|Warm Dortmund welcome delights Tuchel|
|Silva vows to fight for Madrid place|
|Mancini hints at Shaqiri and Santon departures|
|Bojan raring to go after return from injury|
|Babel backs Firmino to shine at Liverpool|
|Falcao must wait to impress, warns Chelsea favourite|
|Bartomeu: Deal in place for Turan|
|Parejo re-signs with Valencia|
|MLS Review: Sounders return to winning ways|
|Klinsmann unhappy with USA performance|
|High hopes for Paraguay - Diaz|
|Gareca: More to come from Peru|
|Gerrard had European offers|
|Argentina out to spoil Chile´s party - Martino|
|Sampaoli: Chile won´t change style|
|Di Maria will come good at United - Rojo|
|Peru 2 Paraguay 0: Gareca´s men finish third at Copa|
|United States 4 Guatemala 0: Klinsmann´s men win comfortably|
|´I’d prefer no-one to know my name´ - Bassett|