Samuel Chukwueze snatched a dramatic 88th-minute equaliser to send Unai Emery's side through to the last four and will face either Liverpool or Benfica.
Four minutes after coming on as a substitute, Chukwueze swept home a cross by Gerard Moreno to cancel out Robert Lewandowski's 52nd-minute opener and send the LaLiga side through by virtue of a 2-1 aggregate scoreline.
Villarreal had withstood mounting Bayern pressure in the second half, with Lucas Hernandez and Thomas Muller among those who had a chance to win it before the visitors sealed the deal with extra-time looming.
The hosts had looked listless for much of the first period and it took until just before the half-hour mark for them to muster a shot on target when Jamal Musiala headed straight at Villarreal keeper Geronimo Rulli.
But it was a different story after the break as Bayern finally got into gear, and Dayot Upamecano should have scored from a clever cut-back by the busy Leroy Sane in the 51st minute.
Lewandowski ended a strong spell of pressure by poking Bayern in front on the night moments later, sparking a spell of pressure that saw Hernandez shoot straight at Rulli, and Muller miss a glorious chance with a close-range header from another Sane cross.
In the midst of the chances, Moreno had served a warning by flashing the ball across the face of the Bayern box on a swift counter-attack, and that danger became a reality four minutes after Chukwueze's introduction.
The Nigerian kept his cool to fire another Moreno cross past Manuel Neuer and the 'Yellow Submarine' saw out the dying moments to secure a famous aggregate win and a place in the last four.
Villarreal managed just two shots on target across both legs and that was all they needed.