Christian Noboa's superb free-kick earned Rostov a shock 3-2 Champions League win over Bayern Munich in Russia on Wednesday, leaving Carlo Ancelotti's side facing a tough last-16 draw.
Douglas Costa rifled Bayern ahead on 35 minutes at the Olimp-2 stadium, but Rostov equalised through Sardar Azmoun on the stroke of half-time before going ahead courtesy of a Dmitri Poloz penalty.
Juan Bernat swiftly levelled for the Germans, but Ecuador international Noboa fired competition debutants Rostov to a first group stage victory with the winner on 67 minutes.
While Bayern were already assured of qualifying for the knockout stages, they will do so as group runners-up after Atletico Madrid claimed top spot with a 2-0 win over PSV Eindhoven later in the evening.
Bayern made the 2,100-kilometre trip east without goalkeeper Manuel Neuer, Arturo Vidal and Arjen Robben through injury, while injury-prone centre-back Holger Badstuber started for the first time since February.
The Bavarian giants thumped Rostov 5-0 in the opening fixture in September but lost their position at the top of the Bundesliga to RB Leipzig this past weekend following a 1-0 defeat at rivals Borussia Dortmund.
Aleksandr Erokhin nearly headed the Russian outfit ahead after hesitant defending allowed him to nip in between Badstuber and goalkeeper Sven Ulreich only for Bernat to race back and clear off the line.
Renato Sanches, making his first Champions League start this term, tested Soslan Dzhanaev with a swerving effort from the edge of the area before Costa fired just over from a similar position.
The pair were both involved as Bayern broke the deadlock with Sanches bursting into the area down the left and Costa drilling home after Cesar Navas's weak clearance rolled invitingly into the Brazilian's path.
But Iranian international Azmoun levelled for Rostov just before the break after turning Jerome Boateng to coolly slot past Ulreich.
And the hosts grabbed a surprise lead after Boateng upended Noboa inside the box, with Poloz confidently tucking away the penalty for his third goal in five European matches.
Bayern hit back immediately as Franck Ribery slipped in Bernat, who lashed home from close range, but Rostov claimed a memorable win as Noboa's strike left Ulreich clutching at thin air.