The defeat condemned Juve to their third consecutive exit at the round-of-16 stage and came as a huge surprise following a 1-1 draw in Spain last month.
Juve dominated the first half and were unfortunate not to go into the break in front after Dusan Vlahovic’s brilliant flicked effort came back off the crossbar, but they could not keep up the pressure in the second period.
Villarreal were content to sit back and wait for their moment, which came in the 78th minute after the visitors were awarded a penalty following a VAR review, with substitute Gerard Moreno, who had only just come on, squeezing the spot kick home.
Juve threw on Argentine striker Paulo Dybala as they looked to level the tie, but goals down the other end from defender Pau Torres and another penalty, this time converted by Arnaut Danjuma, completed a famous win for Unai Emery’s team.
It is the first time Emery has progressed from a tie in the knockout stages of the Champions League, while Villarreal had not qualified for the quarter-finals of the competition since 2008-09.
“I actually missed the last penalty I took in a game, but everyone had my back and I knew I was going to score,” Moreno said.
“Once we got ahead we were more comfortable. We showed that we are always able to compete with the best at the highest level, whoever is on the pitch.”
Juventus came into the last 16 having also enjoyed an impressive group-stage campaign where they finished top ahead of the current holders Chelsea.
A blistering start saw Spanish striker Alvaro Morata denied by a fine save from Villarreal goalkeeper Geronimo Rulli, giving the home fans hope that progression to the last eight would be a smooth process.
January signing Vlahovic was proving to be a real handful, drilling wide before his improvised effort came out off the woodwork.
Villarreal were enjoying plenty of possession, but could not do much with it. They looked more comfortable after the break, however, as Juve struggled to keep up their momentum.
Daniele Rugani’s lunging tackle on Francis Coquelin gave Villarreal the chance to lead the tie for the first time. Juve keeper Wojciech Szczesny, who saved a penalty at the weekend, almost kept out the spot kick, but saw the ball squirm through his hands.
Torres’s finish from a corner sparked wild scenes of celebration with Villarreal knowing the job was done, even though there was still time for another converted penalty, after Matthijs de Ligtâs handball.
Having dominated for such long periods, only Juve will know how they managed to lose by three goals.
“I think the team played well for over 75 minutes,” Juve coach Massimiliano Allegri said. “In the second half, Villarreal decided to just defend in block but they had one chance and they took it.
“We had good chances in the first half, fewer in the second because Villarreal started defending with 11 men, clearly trying to bring the game to extra time. Then that (opening) goal changed everything.”
Additional reporting from Reuters