Leipzig boosted its chances of advancing to the knockout stage of the Champions League by handing titleholder Real Madrid its first loss of the season on Tuesday,
The German club won 3-2 and now only needs to draw its last group match at Shakhtar Donetsk - which drew 1-1 at Celtic on Tuesday - to advance to the last 16.
Leipzig reached nine points in Group F, one behind Madrid, which had already secured its spot in the round of 16. Leipzig is three points ahead of Shakhtar, while Celtic is last with two points.
Madrid had been unbeaten in 16 matches in all competitions this season, with 14 wins and two draws. The European champion played without several regular starters, including Luka Modric, Federico Valverde and Ballon d'Or winner Karim Benzema.
Leipzig got off to a strong start and Josko Gvardiol scored his first Champions League goal in the 13th minute off the rebound of a save by Madrid goalkeeper Thibaut Courtois. Christopher Nkunku added to the lead five minutes later with a shot from inside the area but Vinicius Junior pulled Madrid closer with a header from near the penalty spot in the 44th.
Madrid had a few scoring chances in the second half but substitute Timo Werner sealed the victory for the hosts from close range after a cross by Mohamed Simakan in the 81st.
Rodrygo gave Madrid its second goal by converting a penalty kick late in stoppage time.
Leipzig reached the Champions League semifinals in 2020 after defeating Madrid rival Atletico Madrid in the last eight. It was eventually eliminated by Paris Saint-Germain.
Madrid had already reached the next round after winning its first four three matches before a draw at Shakhtar in the previous round. Madrid could have secured first place in the group with a draw. It will close out the group stage at home against winless Celtic.
Madrid coach Carlo Ancelotti set up the team without Eduardo Camavinga in midfield and Marco Asensio in attack. Eden Hazard came on as a second-half substitute.
Madrid had won its last four away games in the group stage of the Champions League, all without conceding any goals.
A moment of silence was held before the match in honor of Red Bull founder Dietrich Mateschitz, who died this weekend.
Madrid was unbeaten in its last 13 games against German teams, a run dating to the quarterfinals of the 2013-14 season, when it was defeated by Borussia Dortmund but still advanced.