Real Madrid edged out Union Berlin in a thrilling encounter to finish the Champions League group stage with a 100% record and deny the German side a place in the Europa League.
The German side took a slender lead into half time after Frederik Ronnow denied Luka Modric from the penalty spot moments before Kevin Volland opened the scoring.
Joselu turned the game on its head in the second half, netting an 11-minute brace to move the visitors into the lead, before Alex Kral's late piledriver set up a grandstand finish.
But as the hosts searched for a winning goal that would have sent them into the Europa League, Dani Ceballos dashed those dreams with a deflected strike that ensured Real Madrid rounded off the group stage with a perfect record.
While Union knew this would be their final game in their first-ever Champions League campaign, they came into the contest knowing that a win and a Braga defeat would see them clinch third spot and a place in the Europa League.
With the vociferous support urging them on, Union made a quick start to the encounter, with Kevin Behrens forcing Kepa Arrizabalaga to tip over the crossbar.
© Reuters
After surviving that early scare, Real Madrid threatened through the in-form Jude Bellingham, who saw his effort kept out by the resolute Ronnow.
The Union Berlin goalkeeper then watched Joselu hit the woodwork with a headed effort from Fran Garcia's lofted cross.
As the first half drifted into the closing stages, Real Madrid were presented with the chance to take the lead from the penalty spot after Diogo Leite was penalised for a handball.
The responsibility fell to the experienced Modric, who saw his tame spot-kick smartly saved by Ronnow to the relief of the home support.
From spurning a chance to go in front, Real Madrid found themselves behind just a minute later when Volland punished David Alaba for a defensive error.
The Austria international failed to deal with Behrens's flick-on, causing the ball to run into the box, where Volland held off the pressure from Lucas Vazquez to slot past Arrizabalaga.
With their unbeaten European record under threat, Carlo Ancelotti's charges made a purposeful start to the second period.
© Reuters
Ronnow made a smart stop to thwart Vazquez, before the Union goalkeeper pulled off a sublime reaction save to deny Rodrygo at point-blank range.
Unfortunately for the 31-year-old shot-stopper, there was nothing that he could do to prevent Joselu from nodding home from Rodrygo's clipped cross in the 61st minute.
The Spain international then produced a clinical diving header from Garcia's near-post delivery to turn the game firmly in the visitors' favour.
However, just as Union appeared to be down and out, Kral came off the bench to thump a low strike into the bottom corner, putting his side back on level terms.
Unfortunately for Nenad Bjelica's team, their hopes of claiming a winning goal and third spot lasted just three minutes before Dani Ceballos fired past Ronnow with the help of a deflection to ensure that Union finished bottom of Group C.
While Braga finished third and Napoli ended up second, Real Madrid topped the group with a perfect record to make a significant statement ahead of the knockout rounds.
No Data Analysis info