The Germans were trailing as the match entered injury time at the end of regulation time in the second leg only for Thomas Muller to head home a thumping equaliser.
The five-time European champions pushed on in extra-time as goals from Thiago and Kingsley Coman -- on loan at Bayern from Italians Juve -- sealed a win that seemed improbable midway through the second half.
After 73 minutes, visitors Juve -- who had trailed 2-0 in the first leg before battling back for a draw -- led 4-2 on aggregate thanks to early goals from Paul Pogba and Juan Cuadrado.
But Robert Lewandowski headed home from the influential Douglas Costa to give the home fans hope as Bayern, beaten once in their previous 15 games, started to prove their mettle.
Coach Pep Guardiola's tactical changes made the difference and the Spaniard has now reached at least the quarterfinal stage of the Champions League in all seven of his seasons as a manager.
Much attention will also focus on 19-year-old Coman, the Juventus loanee who came on for Bayern on the hourmark and who had already made a big impact before scoring the final goal to seal the dramatic win.
Elsewhere, reigning champions Barcelona cruised into the quarterfinals of the Champions League for the ninth successive year after beating Arsenal 3-1 at home to register a 5-1 aggregate win.
The much-vaunted front three of Neymar, Luis Suarez and Lionel Messi -- nicknamed MSN -- lived up to their billing by all scoring for the home side.
In-between, Egypt's Mohamed Elneny netted his first goal as a spirited Arsenal briefly leveled yet they squandered too many presentable chances to make an impact.
Suarez struck a stunning volley for his 43rd goal of the season before Messi chipped home in familiar style late on to register his ninth strike against Arsenal, the Champions League team he has punished the most.
Barca, one of just two teams to go through the group stages unbeaten (with rivals Real Madrid the other), extended their record unbeaten run to 38 matches.
"It is difficult to take to go out but I believe we produced quality performance against probably the best team in Europe," Arsenal coach Arsene Wenger told British TV afterwards.
Arsenal fans, meanwhile, have watched their season fall apart since the start of the year.
Top of the English Premier League in early January, the Gunners now trail leaders Leicester by 11 points.
In the space of four days, they have crashed out of the FA Cup (to Watford) and the Champions League as well, intensifying pressure on Wenger.
Joining Bayern and Barcelona in the hat for Friday's Champions League quarterfinal draw are Atletico Madrid, Benfica, Manchester City, PSG, Real Madrid and Wolfsburg.