Manchester United went into the last 16 of the Champions League as winners of Group A after a 2-1 win over CSKA Moscow at Old Trafford.
Romelu Lukaku and Marcus Rashford secured the win for Jose Mourinho's side on Tuesday after Alan Dzagoev had put the Russian side ahead.
A 1-0 defeat at Basel on matchday five meant United were not certain of a place in the knockouts heading into the encounter, although it would have taken a sizeable win for CSKA and a victory for Basel in Benfica to see them miss out on the top two.
Mourinho made six changes to the side that beat Arsenal on Saturday, with Luke Shaw handed his first start of the season as the United boss kept one eye on the looming Manchester derby, and it looked as though the weakened team could be heading for only a fourth loss of the season when Dzagoev fortuitously gave the visitors the lead.
However, Lukaku and Rashford made the most of two sublime passes from Paul Pogba and Juan Mata in the space of two second-half minutes to complete the comeback and seal top spot in the group, with CSKA forced to settle for a Europa League place.
United's focus now turns to the top-of-the-table clash with neighbours Manchester City on Sunday, before they learn which team they will face in the last 16 at Monday's draw in Nyon.
6 - Paul Pogba has provided six assists in his 12 games in all competitions for Man Utd this season, as many as he did in his 51 games for them last term. Selfless. pic.twitter.com/V4yloNJoJD-- OptaJoe (@OptaJoe) December 5, 2017
United nearly had the lead in only the fourth minute, as a lightning counter-attack involving Mata and Lukaku ended with Rashford rattling the base of the right-hand post from close range.
It needed Igor Akinfeev to deny Rashford from his second attempt of the match, the goalkeeper getting down swiftly to his left to claw away the forward's effort after Mata had set him up quite superbly.
Shaw had looked bright in the early exchanges and it was soon his turn to test Akinfeev, his rasping volley from Antonio Valencia's cross stinging the keeper's hands before he just managed to stop Lukaku netting the rebound.
United's standards slipped in the latter stages of the half and they paid the price in injury time, albeit in controversial fashion. Mario Fernandes burst clear down United's left, his low cross was fired towards goal by Vitinho, and the ball hit the back of Dzagoev and went into the net, with the officials unmoved by the home side's appeals, presumably given that Daley Blind had slid inadvertently out of play and was therefore considered to be on the goal line.
The hosts injected a bit more pace into their play as they chased an equaliser, with Rashford again testing Akinfeev after a strong run before whipping a free-kick over the bar via a deflection.
United had CSKA pegged back in their half and the pressure finally told in the 64th minute, as Pogba's delightful delivery from 30 yards out was prodded past Akinfeev by the stretching Lukaku.
Sixty-six seconds later, the turnaround was complete. Mata's exquisite touch and lobbed pass was drilled into the bottom-right corner by Rashford, who had been allowed time to watch the ball bounce into the penalty area.
@JuanMata8 played a delightful ball over the top, which @MarcusRashford latched onto, and finished in style! #MUFC#UCLpic.twitter.com/8RRW4joUgT-- Manchester United (@ManUtd) December 5, 2017
Mourinho handed Anthony Martial a run-out from the bench, along with youngsters Scott McTominay and Axel Tuanzebe, as Ander Herrera, Valencia and Lukaku were given a welcome rest before the meeting with City.
Dzagoev had a chance to level the scores seven minutes from time, but Sergio Romero stuck out a foot to deny the Russia international and ensure United finished a satisfactory group phase with five wins from six games.