With the aggregate score at 2-2, Real were still qualified for the semi-finals thanks to the away goals rule. And their cause was aided when Ronaldo levelled on the night. The Portuguese striker steered Casemiro's cross into the far corner 14 minutes from time.
But a minute later the ball ricocheted around their box and Sergio Ramos turned into his own net to give Bayern a 2-1 lead. With the aggregate score at 3-3 and each tema having scored two away goals, 30 minutes of extra-time beckoned.
But as the clock ticked down, the momentum shifted Madrid's way when Bayern's Arturo Vidal was sent off for his second bookable offence.
Diminished, Bayern were soon destroyed. Shortly before the midway point in extra-time, Ronaldo scored his second of the night to make it 2-2 and he effectively sealed the tie when he completed his hat trick after 110 minutes.
Marco Asensio added a sensational solo goal two minutes later to rub salt in Bayern's wounds.
"To score six goals against a team like Bayern Munich isn't easy so we deserved to go through," Ronaldo told Spanish TV station Antena 3. "Real Madrid is Real Madrid, we are used to suffering and we are happy to be in the semis once again."
But Bayern were furious as video replays showed that Ronaldo's second and third goals were clearly offside.
"The card which led to Arturo's sending off wasn't a card and then the two goals from Cristiano are offside so clearly we are not happy," said Bayern coach Carlo Ancelotti. "In a quarter-final you have to put a better referee, or it is the moment to introduce video refereeing, which is what Uefa are trying because there are too many errors."
Madrid boss Zinedine Zidane said: "We can say that we've just played against the toughest team we've faced this season. It was a relly difficult game but we've deserved to go through. We've scored six goals in two matches.
"I'm proud of these players because they've performed well collectively. We kept our calm even when we were missing chances and we defended well.
"We're stil lin with a chance of defending our Champions League title - because we're in the next round but we've got to continue doing what we've been doing."