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'
|Garcia proud of resilient Roma|
|Rio Ferdinand retires from football|
|World Cup allocation to remain unchanged, Blatter confirms|
|Blatter defiant after re-election|
|Barkley break to benefit Everton - Jones|
|Bilic proud of Besiktas achievements following his final game in charge|
|Vietto encourages Atletico bid|
|Di Santo in demand, claims agent|
|Arteta: Arsenal harbour high ambitions for next season|
|Wilmots considering Schalke offer|
|McCall: Rangers need a miracle|
|Sporting Kansas City 4 Dallas 0: Nemeth, Zusi destroy 10-man visitors|
|Geferson replaces Marcelo for Copa America|
|PSG captain Silva in doubt for Coupe de France final|
|Valverde: Bilbao to stick to style in Copa final|
|´Another round of indictments´ expected in FIFA case|
|Youngsters promoted to Australia´s squad to face Kyrgyzstan|
|Disappointed FFA, US Soccer still want change|
|Gutierrez: Ashley abandoned me|
|US senator urges Blatter to release Garcia Report|
|Gutierrez, Taylor released by Newcastle|
|Figo calls on re-elected Blatter to resign after ´dark day´ for football|
|Szczesny blasts father over ´idiotic´ comments|
|Blatter vows to leave ´strong´ FIFA|
|Blatter re-elected as FIFA president|
|BREAKING NEWS: FIFA elections set for second round of voting|
|Atsu wings in for Bournemouth campaign|
|Klopp: Pokal final not about me|
|Clement says Real goodbyes|
|Inter v Empoli: Icardi looking for final flourish|
|BREAKING NEWS: Blatter - I will fix FIFA|
|Northern Ireland v Qatar: O´Neill keen to prepare for Romania test|
|Palestine drop proposal for Israel suspension|
|Suarez will only get better, warns Iniesta|
|Martinez keen to recruit quickly|
|Monk keen to build on successful Swansea campaign|
|Fit-again Suarez set to aid Barca´s treble quest|
|Anonymous ´bomb´ threat received at FIFA Congress|
|Qatar organisers insist World Cup bid met ´highest ethical standards´|
|Wilkinson and Sorensen leave Stoke|
|Blatter: You can´t ask everyone to behave ethically just like that|
|Van Bronckhorst positive about Feyenoord future|
|Australian police to look into FFA-Warner dealings|
|Dardai signs Hertha deal|
|Protester interrupts FIFA Congress|
|Spurs complete Wimmer signing|
|Warner questions charges following release|
|Mexico v Guatemala: Herrera´s men kick off Copa preparations|
|New Zealand no longer supporting Blatter|
|´Post-World Cup trauma´ affected Mertesacker|
|Racing Club 0 Guarani 0 (0-1 agg): Draw sees Paraguayans through|
|Hamburg shocked by Karlsruher attack - Labbadia|
|Serie A Preview: Napoli, Lazio eye Champions League|
|Hodgson will not overstay England welcome|
|Scholes: United must keep Di Maria|
|Leyton Orient appoint Hendon|
|Benteke has a buy-out clause - Sherwood|
|US Soccer will support Prince Ali in FIFA election|
|Dynamo disappointed with officials after City friendly abandoned|
|Calls for Suarez appeal gather momentum|
|Eredvisie Review: Vitesse denied by late Uth goal, NAC Breda boost survival hopes|
|Rangers 1 Motherwell 3: McCall´s men facing uphill struggle|
|Hamburg 1 Karlsruher 1: Bundesliga side escape with draw|
|Blatter vows to lead FIFA clear of trouble as corruption scandal rolls on|
|Bundesliga: Bayern Munich season review - League crown not enough to signal successful campaign|
|Genoa forced to wait for UEFA licence|
|Injured Cardozo out of Paraguay squad|
|CONCACAF provisionally dismisses Webb and Li|
|Klopp: Career highlights of a charismatic coach|
|Verona v Juventus: Ogbonna seeks strong Champions League warm-up|
|FA charges Demetriou over betting breaches|
|Atalanta v Milan: Inzaghi faces last chance to prove worth|
|King joins Bournemouth as QPR rebuild begins|
|Plymouth part ways with Sheridan|
|Hernandez banned for three matches|
|Chelsea star Fabregas has nose surgery|
|Blatter: More bad news may follow|
|Galliani hopeful over Ancelotti deal|
|Frontzeck to continue as Hannover coach|
|Tremmel released as Tate waves goodbye to Swansea|
|Arsenal v Aston Villa: Sherwood out to upset holders|
|UEFA open to boycott of World Cup - Platini|
|Porto activate release clause for Casemiro|
|Athletic Bilbao v Barcelona: Catalans seeking second leg of treble|
|Auxerre v Paris Saint-Germain: History beckons for Ligue 1 champions|
|Cole confirms West Ham departure|
|UEFA elect not to boycott FIFA Congress|
|Borussia Dortmund v Wolfsburg: Klopp aiming for triumphant farewell|
|Flamini hails Coquelin impact at Arsenal|
|South Africa deny wrongdoing in World Cup bid|
|Benitez confirms Napoli exit|
|McShane among six released by Hull|
|Cerci committed to Milan|
|West Ham expect Collins to return for pre-season|
|Real deny Pogba bid|
|Important to keep Chelsea squad together - Mourinho|
|Alonso: Gerrard was magic|
|Pochettino silent on Ings speculation|
|Visa threatens to ´reassess´ sponsorship amid FIFA scandal|
|Blatter skips FIFA Medical Conference|
|MLS Preview: Revs not out for revenge against Galaxy|
|MLS Review: Sounders go top in West, Timbers and Galaxy win|
|AFC stands by Blatter|
|Matheus ´alright´ after collapse - Markevych|
|Copa Libertadores Review: River, Inter through to semis|
|Signing Toni a ´long shot´ for Adelaide|
|Ramsey good enough for Barca - Coleman|
|Bacuna pushing for Benteke stay|
|Evans stunner settles City friendly in Toronto|
|Banega: Emery a great coach|
|Emery tight-lipped on Sevilla future|
|Argentina finalise Copa America squad|
|Nike issues statement following arrest of FIFA officials|