German champions had done well up to then to force extra time
Cristiano Ronaldo scored a hat-trick to send UEFA Champions League holders Real Madrid through to the semi finals of this season's competition.
The Spanish league leaders triumphed 6-3 on aggregate overall but it came after Bayern Munich forced extra time at the Santiago Bernabeu.
The German champions cancelled out Real's 2-1 first leg lead, but the home side then scored three goals in extra time in the Spanish capital to win 4-2 on the night.
The returning Robert Lewandowski gave Bayern, who needed two goals - the lead on the night from the penalty spot, before Ronaldo levelled with 13 minutes for Real.
But Bayern made it 3-3 on aggregate to force extra time when Sergio Ramos scored an own goal, although Bayern midfielder Arturo Vidal was sent off with six minutes to go of the 90 minutes.
But Real took control shortly before half time in extra time as Ronaldo netted from close range on 104 minutes.
The Portugal captain then found the net again five minutes later to put Real Madrid 5-3 up on aggregate, before Marco Asensio put the icing on the cake on 112 minutes with the La Liga giants' sixth goal of the tie.