A stunning header from Junior Messias in the dying minutes handed AC Milan a 1-0 win over Atletico Madrid and kept alive their hopes of qualifying for the last-16 in the Champions League.

Milan arrived in Madrid rooted to the bottom of Group B with only one point and anything but a win against Atletico would have eliminated them from this season's competition.

Wednesday's result means the race to see who will join group winners Liverpool in the next round will go down to the wire. Porto, who are on five points after losing 2-0 at Anfield, as well as Milan and Atletico, who are tied on four points, will have to wait until the final round of fixtures to decide who will finish second, and hence progress to the last-16.

Real Madrid booked a spot in the knockout stages with a match to spare after strolling to a 3-0 win at Moldovan side Sheriff Tiraspol in their lop-sided Group D clash.

David Alaba fired the visitors ahead with a deflected free kick in the 30th minute, with a shot from 22 metres leaving Sheriff goalkeeper Georgios Athanasiadis stranded after it clipped Cristiano's outstretched foot.

Midfielder Toni Kroos doubled Real's lead on the stroke of half-time with a fine shot which cannoned in off the underside of the crossbar after a flowing move left the German midfielder with time and space to pick his spot.

Karim Benzema made it 3-0 with a sublime effort from the edge of the penalty area into the bottom corner after he was teed up by left back Ferland Mendy in the 55th minute, as Real kept their foot on the pedal.

Real top the group on 12 points from five games, two more than second-placed Inter Milan with the result also sending the Italian champions through after they beat Shakhtar Donetsk 2-0. Edin Dzeko scored twice in six second-half minutes to earn the victory for the reigning Serie A champions.

A good night for Dzeko

Third-placed Sheriff, who stunned Real 2-1 in the reverse fixture in September, are third on six points and assured of carrying on in the Europa League after the winter break. Fourth-placed Shakhtar have one point.

Real are at home to Inter in their final group match while Sheriff visit Shakhtar on 7 December.

RB Leipzig scored four goals in a rampant first-half performance and added one more after the break for a comprehensive 5-0 victory away at Club Brugge that lifted them off the foot of Group A.

Leipzig are now in pole position to finish third in the standings and secure a berth in the Europa League, ahead of their Belgian hosts.

Manchester City and Paris Saint-Germain, who were in action at the Etihad, have secured the top two places in the group and will progress to the last-16.

Emil Forsberg scored twice, including one from the penalty spot, with Christopher Nkunku and Andre Silva adding the other two for Leipzig in the opening 45 minutes.

Nkunku then got the fifth in stoppage time at the end of the second half.

Sporting Lisbon beat 10-man Borussia Dortmund 3-1 with two goals from Pedro Goncalves to clinch their spot in the knockout stages and eliminate the Germans from the competition.

Goncalves struck twice in the first half to lead his team to their 10th straight victory in all competitions and nine points in Group C, three ahead of the Germans with a game left and a better head-to-head, after losing 1-0 in Dortmund in September.

Dortmund, without injured striker Erling Haaland, desperately tried to fight back in the second half but had Emre Can sent off in the 74th minute before conceding a third goal from Pedro Porro seven minutes later.

Dortmund, who scored in stoppage-time through Donyell Malen, will go into the Europa League as the third-placed team in the group. Ajax clinched top spot with a 2-1 win over bottom side Besiktas, their fifth victory in five matches.

Former West Ham striker Sebastian Haller came off the bench at the start of the second half and netted goals in the 54th and 69th minutes as the Amsterdam side overturned a half-time deficit to keep up their 100% run in the group.

The 27-year-old has nine goals in five games in the group phase, tied with Robert Lewandowski of Bayern Munich in this season's Champions League scoring charts.

Besiktas, who have lost all five of their group matches, had gone ahead after Ajax fullback Noussair Mazraoui handled the ball and Rachid Ghezzal tucked away a 22nd-minute spot kick.