Manchester United s Cristiano Ronaldo, left, celebrates with teammate Diogo Dalot after scoring the match winning goal (AP)
Making his record 178th appearance in the competition, Ronaldo latched onto a loose ball in the area and slotted a finish under Villarreal goalkeeper Geronimo Rulli before running to the fans and removing his jersey to reveal his muscular physique.
It was Ronaldo's fifth goal in five games since joining from Juventus for a second spell at Old Trafford and definitely his most important.
Villarreal looked like handing United a second straight loss in Group F _ after the Premier League team's shocking 2-1 defeat at Swiss outsider Young Boys two weeks ago _ by going in front in the 53rd through Paco Alcacer, who poked in a finish through the legs of United goalkeeper David De Gea following a cross by Arnaut Danjuma off the outside of his right boot.
United had been outplayed by that point but equalized within seven minutes through Alex Telles, who was picked out by a pinpoint pass from Bruno Fernandes at a free kick. The Brazilian left back took a step back at the edge of the area and struck a first-time volley that swerved inside the far post.
Villarreal had started with a 2-2 draw at home to Atalanta.
The result broke a run of four straight 0-0s between the teams in Champions League play, dating back to pair group matches in 2005 and 2008.
The teams also met in the Europa League final in May, with Villarreal winning a penalty shootout following a 1-1 draw.