Anderson Talisca scored a late winner for Besiktas as the Group G winners won 2-1 at 10-man RB Leipzig, the result sending Ralph Hasenhuttl's side into the Europa League.
Leipzig needed to better Porto's result against Monaco to stand any chance of Champions League progression, but it was not going to plan from the moment Alvaro Negredo gave the visitors an early lead from the penalty spot.
The hosts peppered the Besiktas goal but were frustrated by the outstanding Tolga Zengin in goal. Captain Willi Orban hit the post while Timo Werner and Jean-Kevin Augustin both had goals chalked off for offside on a frustrating night for the hosts, who also had Stefan Ilsanker sent off.
Naby Keita briefly restored hope after firing a low shot past Zengin with just three minutes remaining before Talisca hit back in the last minute to seal an impressive away victory.
The result, coupled with Porto's 5-2 win over Monaco, means Leipzig head into the Europa League while Besiktas finish top with an impressive tally of 14 points and will head into Monday's draw still unbeaten in the tournament.
10 - Tolga Zengin has made the most saves in a single Champions League game amongst the Turkish goalkeepers (10).
Rüştü Reçber - Fenerbahçe vs Lyon (19.10.2004) - 9
Sinan Bolat - Olympiakos vs Standard Liège (20.10.2009) - 9
Wall. pic.twitter.com/jZEXMph8V2 — OptaCan (@OptaCan) December 6, 2017
Leipzig had started brightly but it was the visitors who went ahead just 10 minutes in after Orban conceded a penalty by bringing down Jeremain Lens.
Negredo stepped up and rather casually rolled the ball home to give Besiktas the lead, much to the displeasure of a vocal home crowd.
Back came the hosts, Orban slamming a shot against the base of the post after Diego Demme's corner before Werner thought he had equalised, only to be denied by a very late offside decision.
1470 - @AlvaroNegredo9 has scored his first Champions League goal after 1470 days (27.11.2013 - Manchester City vs Viktoria Plzen). It's also his first ever penalty goal in the competition. Awakening. pic.twitter.com/IH1J1xtPhN — OptaCan (@OptaCan) December 6, 2017
Undeterred, Leipzig continued to press for an equaliser but left themselves wide open to the counter-attack and were almost made to pay by Negredo, who opted to pass to Lens when he ought to have gone for goal himself.
Yet the chances continued to come, Werner and Bruma both testing goalkeeper Zengin but unable to find a way past in an entertaining first half of attacking football.
The second half started in the same fashion with Augustin firing just wide within minutes of the restart before Werner dribbled into the danger area but saw his shot tipped around the post by Zengin.
The Besiktas goalkeeper was called in action again shortly afterwards denying Werner from close range and then saving a Keita header as Leipzig piled on the pressure in search of an equaliser.
Still Leipzig pressed, Kevin Kampl jinking past defenders and into the area but his dinked effort was just tipped to safety by Zengin.
Leipzig did manage to get the ball into the net, Augustin taking a touch before swivelling and firing past Zengin only to see the offside flag raised once again.
There was more misery to follow with Ilsanker picking up a second yellow card for a foul on the breaking Cenk Tosun with eight minutes to go, but Keita was still able to make the breakthrough.
The ball fell nicely to the midfielder on the edge of the area and he fired a low, left-footed shot past Zengin.
However, parity did not last long, Orkan Cinar picking out Talisca to volley home the winner and bring an end to Leipzig's Champions League campaign.