European champions Real Madrid suffered a first defeat this season as RB Leipzig rekindled their hopes of booking their place in the Champions League last 16.
Croatia defender Josko Gvardiol scored the opener as he headed the hosts ahead before France forward Christopher Nkunku doubled the advantage.
Vinicius Jr. gave the visitors a lifeline as he reduced the deficit but ex-Chelsea forward Timo Werner made sure of a memorable win for RB Leipzig with the 3rd goal for the Bundesliga outfits.
Real, who had already qualified for the knockout stage prior, scored a late second with a penalty from Rodrygo to end the 5-goal thriller.
With Celtic holding Shakhtar Donetsk in Glasgow in the other game in Group F, second-placed RB Leipzig have nine points, three more than Shakhtar who are in third spot.
Shakhtar host RB Leipzig in Poland on 2 November.
Â