Real Madrid started their Champions League title defence with a hard-fought 3-1 home win over Stuttgart on Tuesday thanks to late goals by Antonio Rudiger and teenaged substitute Endrick.
Stuttgart were arguably the superior side at a sold-out Santiago Bernabeu stadium, with Real Madrid goalkeeper Thibaut Courtois having to make a string of critical saves to deny efforts by the German side.
Real, however, got the lead in the first minute of the second half in a quick counter-attack when Rodrygo crossed for Kylian Mbappe to strike from close range.
Stuttgart found the equaliser with a header by Deniz Undav in the 68th minute but Real substitute Luka Modric lifted a corner to meet Rudiger who nodded a header past the goalkeeper in the 83rd.
Eighteen-year-old Endrick slotted home a powerful shot from long range deep into added time to secure an edgy win for the local side.
Manager Carlo Ancelotti, faced with a selection puzzle in defence with David Alaba still recovering from an ACL tear sustained last season and Eder Militao struggling with a lingering leg muscle problem, started fullback Dani Carvajal as a centre back and Stuttgart went aggressively after the right side of Real's defence, almost scoring on several occasions.
Carvajal and stand-in fullback Lucas Vazquez, both 1.73 metres tall, were easy targets for Stuttgart and were often caught out of position, giving the German side chances throughout the first half.
An inspired Courtois produced world-class saves from efforts by Jamie Leweling, Enzo Millot and Angelo Stiller within the first 20 minutes.
Real tried to hit back, with Mbappe, Vinicius Jr and Rodrygo all wasting good chances, but it was Stuttgart who came close to scoring through Undav in a counter-attack in the 29th minute when his strike was deflected on to the crossbar by Carvajal.
Ancelotti brought Militao off the bench at halftime, moving Carvajal to his original fullback position in a bid to fix his side's issues, and a defensive mistake by Stuttgart's Maximilian Mittelstadt gave Real the opener in the first minute of the second half.
Aurelien Tchouameni sent a long ball towards Rodrygo on the right touchline that Mittelstadt failed to clear, leaving the Brazilian forward unmarked and able to control the ball in his stride before crossing to Mbappe who tapped into the empty net from the far post.
Real Madrid kept piling on the pressure, with Rodrygo missing a couple of chances and Vinicius Jr hitting the crossbar from the edge of the box in the 59th minute.
Stuttgart were still dangerous on the break and Courtois had to make a couple of saves from efforts by Leweling before Undav's header from a corner levelled the match.
Stuttgart kept threatening a chaotic Real defence but the Spanish side got the lead again through Ruediger.
Vinicius Jr missed a sitter one-on-one against Stuttgart goalkeeper Alexander Nuebel in the 93rd minute, two minutes before Endrick's rocket strike from way outside the box.