Cristiano Ronaldo plundered a hat-trick as Real Madrid saw off 10-man Bayern Munich 4-2 after extra-time at the Bernabeu to secure the holders' place in the semi-finals of the Champions League.
Robert Lewandowski, who missed the first leg with a shoulder problem, put Bayern ahead on the night from the penalty spot to level the tie on aggregate following Real's 2-1 win in Munich, where Ronaldo had scored twice.
Ronaldo's bullet diving header in the 76th minute then looked to have sent Real through, but a bizarre own goal from captain Sergio Ramos moments later levelled things up at 3-3 overall.
The Germans had to head into extra-time with only 10 men following a second caution for midfielder Arturo Vidal, which looked harsh on the Chile international.
Real made their numerical advantage count as Ronaldo grabbed his second of the match in the 105th minute - taking him to 100 Champions League goals in the process - although he looked to have been offside.
There was also some debate about Ronaldo's hat-trick goal four minutes later, with the Portugal forward possibly offside again when he knocked the ball in following a fine run from Marcelo.
Substitute Marco Asensio added a fourth on the break in the 112th minute to complete a 6-3 aggregate win for the Spanish league leaders as former Real boss Carlo Ancelotti endured a miserable return to the Bernabeu.
Real, who host title rivals Barcelona in El Clasico on Sunday, were without injured Wales forward Gareth Bale.
The German champions, meanwhile, were missing suspended defender Javi Martinez after his red card in Munich.
Needing to score at least twice to avoid exiting the competition, Bayern produced a strong start as former Real winger Arjen Robben fired into the side netting.
Real, seeking to make it a record seventh straight Champions League semi-final appearance, finally came alive as the half-hour mark approached when Bayern keeper Manuel Neuer pushed behind a low drive from defender Dani Carvajal.
Toni Kroos then forced his old team-mate Neuer into another save with a low 25-yard drive as Real finished the first half on top.
In the upper stands of the Bernabeu, police moved in to calm some disturbances among the away supporters.
Bayern began the second half on the front foot as Robben's hooked shot was cleared off the line by Marcelo.
The visitors, though, did not have to wait long for the breakthrough, which came after 53 minutes.
Robben was caught as Casemiro came across to make a challenge inside the area, and Hungarian referee Viktor Kassai pointed to the spot despite Real protests of a dive.
Lewandowski kept his cool from 12 yards, clipping the ball in to the left as Keylor Navas dived the wrong way.
The Germans maintained their momentum with both Vidal and Franck Ribery having chances.
Real, though, restored their aggregate lead after 76 minutes when Ronaldo sent a diving header into the bottom right corner from Casemiro's angled cross.
Bayern, however, responded almost immediately and went 2-1 ahead on the night thanks to Ramos' own goal.
The ball was lofted up towards substitute Thomas Muller, who chested it down towards Lewandowski only for Nacho Fernandez to knock it onto Ramos, who was powerless to stop the ball rolling into an empty net past the wrong-footed Navas.
Lucas Vazquez volleyed wide at the far post before Bayern were reduced to 10 men as Vidal collected another caution with six minutes left following a sliding challenge on Asensio, although he looked to have won the ball first.
Real pressed early in the first period of extra time as Neuer beat away Ronaldo's angled drive before, at the other end, Bayern substitute Joshua Kimmich just failed to get on the end of Douglas Costa's ball across the face of goal.
Ronaldo then put Real back in the ascendency with his second goal of the night - and 100th in the competition.
He produced a clinical finish to chest down a chip into the Bayern penalty area from Ramos and dispatch a low shot past Neuer into the bottom left corner, but replays showed the Portugal forward was offside.
There was an argument about his third as well as Ronaldo was set up at the far post by a driving run from left-back Marcelo, with Asensio's individual effort wrapping things up.