Barcelona coach Ernesto Valverde did not play Argentina star striker Lionel Messi in the first eleven at Turin, later introducing him as a second-half substitute as a 0-0 draw against Juventus sent the five-time European champions through as winners of Group D.
Willian scored twice and won a pair of penalties as Chelsea thrashed 10-man Qarabag 4-0 in Baku to guarantee Antonio Conte's side a top-two finish in Group C.
First-half goals from Eden Hazard and Willian put Chelsea in control, with Cesc Fabregas adding a third before Willian netted again to cap the rout and knock Qarabag out of the competition.
"We did everything well. We should have scored more. It is easy to play with these good players," Hazard said. Atletico Madrid, runners-up twice in the past four years, retained an outside chance of pipping Roma to a place in the knockout stage as Antoine Griezmann snapped an eight-match goal drought in a 2-0 win in Spain.
The French striker broke the deadlock with a spectacular acrobatic effort on 69 minutes, before compatriot Kevin Gameiro added a late second to seal a first win of the campaign for Atletico.
However, they must beat Chelsea at Stamford Bridge in their final game and hope Roma drop points at home to Qarabag to avoid parachuting into the Europa League.
United, who hit the woodwork twice in the first half through Marouane Fellaini and Marcos Rojo, looked on course to secure the point required to punch their ticket to the last 16 in Switzerland before Michael Lang popped up with an 89th- minute winner.
"It's like a dream. Right now I can't believe we won against such a strong team," Swiss international Lang told RTS. "We always thought we could win this match and in the end it was a victory like I had never seen before."
Mourinho blamed United's inability to convert their first-half dominance into goals after watching his side lose their perfect record in the group. "We lost because in the first half we should be 5-0 up but we could not score one goal after being so dominant," Mourinho said.