United were poor in the first half but some terrific David de Gea saves meant the score was goalless going into half-time.
But Villarreal finally made their superiority count when Paco Alcacer gave them the opener after 53 minutes.
United responded well though and they restored parity seven minutes later.
Bruno Fernandes picked out Alex Telles on the edge of the area and the Brazilian produced a wonderful volley which found the corner of the net.
Cristiano Ronaldo then sparked chaotic scenes inside Old Trafford when he scored the winner with virtually the last kick of the game.
Jesse Lingard set up the legendary Portuguese forward inside the box and he made no mistake from close range.
The goal came as a huge relief to Ole Gunnar Solskjaer, who would have had some tough questions to answer should they not have beaten their Spanish opponents.
Fan footage has shown his reaction to Ronaldo’s winner and it’s brilliant.
The Norwegian manager turns around and fist pumps after the goal goes in. He’s then met by Telles, who had been subbed off just before, and the two celebrate together.
They are then joined by Mike Phelan. It makes for a wholesome video and you can watch it below.
You love to see that sort of passion.
The Norwegian manager was ecstatic when discussing his side’s win after the game.
“It’s massive for the players,” Solskjaer said, per Eurosport. “To win games in this fashion after we lost a game in that fashion in Berne [against Young Boys] is great. I’d rather have a win and defeat rather than two draws.
Manchester United 2-1 Villarreal match reaction | The Football Terrace
“It’s a difficult one because we are at home and want to win but they play so well that if we don’t go and press them then they will be happy enough sitting off.”