Match ends, Lokomotiv Moscow 1, Juventus 2.
Juventus sealed their place in the last 16 of the Champions League with an injury-time winner against Lokomotiv Moscow in Group D.
Substitute Douglas Costa struck the decisive blow with a cool finish as the visitors rallied late on.
Aaron Ramsey handed Juve an early lead after Guilherme spilled Cristiano Ronaldo's free-kick, before Aleksey Miranchuk equalised.
Juventus will be joined by Atletico Madrid if they beat Bayer Leverkusen.
Maurizio Sarri made seven changes to his side that won the Turin derby last weekend, handing Ramsey a first European start for the club, and the Juve boss was rewarded early on.
Guilherme allowed Ronaldo's long-range free-kick to bounce and trickle through his legs, and the Welshman tapped his side's 300th Champions League goal into an empty net.
Lokomotiv, who knew victory would have kept their qualification hopes in their own hands, responded after going behind and Miranchuk scored his second goal in as many games against the Italian giants to level.
The forward headed against the post to beat the diving Wojciech Szczesny before converting the loose ball into an empty net.
Ronaldo - who was denied breaking the record for scoring against the most clubs in the Champions League by Ramsey's final touch in the first half - improved after the break.
The Portuguese forward forced Guilherme into a terrific save from a fierce shot as Juve pushed forward, while Leonardo Bonucci had to be sharp to clear Joao Mario's shot off the line at the other end, as the hosts threatened to snatch the winner against the run of play.
Qualification was secured when Costa finished off Gonzalo Higuain's through ball to send his side into the knockout stages, with two group games to play.
Juve become fifth club to hit 300 - the stats
- Juventus have now beaten Lokomotiv Moscow in each of their four meetings in European competition, winning both matches in the 1993-94 Uefa Cup as well as the two matches in the Champions League this season
- Juventus have kept just one clean sheet in their last five group stage matches in the Champions League - this after keeping six shutouts in their previous seven games at this stage of the competition
- Aaron Ramsey's opening goal became the 300th goal Juventus have scored in the Champions League; the fifth club to reach this after Real Madrid, Barcelona, Bayern Munich and Manchester United
- Aleksei Miranchuk's goal for Lokomotiv Moscow (11:45) was the earliest goal the club has scored in the Champions League since Dmitri Loskov netted against Inter Milan in the third minute of their meeting in October 2003 (02:38)
- Miranchuk became the first player to score home and away during the group stages of a Champions League campaign against Juventus since Cristiano Ronaldo back in 2013-14
- Ramsey's goal in the third minute of the match made him the first British player to score a European Cup/Champions League goal for Juventus
- 1Alvim Marinato
- 31RybusBooked at 83mins
- 17ZhemaletdinovSubstituted forCerqueira Paimat 81'minutes
- 23João MárioSubstituted forKolomeytsevat 85'minutes
- 59Al Miranchuk
- 19Macedo Lopes
- 27Cerqueira Paim
- 19BonucciBooked at 39mins
- 12Lobo Silva
- 6KhediraSubstituted forDouglas Costaat 70'minutesBooked at 90mins
- 8RamseySubstituted forBentancurat 64'minutes
- 7Cristiano RonaldoSubstituted forDybalaat 82'minutes
- 2De Sciglio
- 11Douglas Costa
- Ruddy Buquet
- Shots on Target
Second Half ends, Lokomotiv Moscow 1, Juventus 2.
Offside, Lokomotiv Moscow. Maciej Rybus tries a through ball, but Vedran Corluka is caught offside.
Douglas Costa (Juventus) is shown the yellow card for excessive celebration.
Goal! Lokomotiv Moscow 1, Juventus 2. Douglas Costa (Juventus) left footed shot from the centre of the box to the centre of the goal. Assisted by Gonzalo Higuaín.
Corner, Juventus. Conceded by Murilo Cerqueira.
Attempt blocked. Miralem Pjanic (Juventus) right footed shot from outside the box is blocked. Assisted by Adrien Rabiot with a headed pass.
Alex Sandro (Juventus) wins a free kick in the attacking half.
Foul by Aleksey Miranchuk (Lokomotiv Moscow).
Corner, Juventus. Conceded by Benedikt Höwedes.
Douglas Costa (Juventus) wins a free kick in the attacking half.
Foul by Dimitri Barinov (Lokomotiv Moscow).
Hand ball by Adrien Rabiot (Juventus).
Attempt missed. Grzegorz Krychowiak (Lokomotiv Moscow) right footed shot from outside the box is too high. Assisted by Aleksandr Kolomeytsev.
Foul by Daniele Rugani (Juventus).
Éder (Lokomotiv Moscow) wins a free kick on the right wing.
Substitution, Lokomotiv Moscow. Aleksandr Kolomeytsev replaces João Mário.
Attempt missed. Paulo Dybala (Juventus) right footed shot from the centre of the box misses to the left. Assisted by Adrien Rabiot with a cross.
Adrien Rabiot (Juventus) wins a free kick on the left wing.
Foul by Vladislav Ignatjev (Lokomotiv Moscow).