The holders surged through 6-3 on aggregate at an exhilarated Santiago Bernabeu to take their place in Friday’s semi-final draw for a record seventh consecutive year.
But Real were pushed all the way by Bayern, who battled back from a 2-1 first-leg deficit to send the tie into extra time thanks to Robert Lewandowski’s penalty and an own goal from Sergio Ramos.
However, after Arturo Vidal was sent off, Ronaldo hit the century mark in Europe’s top club competition on 104 minutes and completed his hat-trick five minutes later.
Bayern were left incensed, though, as Ronaldo’s second and third goals were clearly offside.
« To score six goals against a team like Bayern Munich isn’t easy so we deserved to go through, » the Portuguese striker 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. »
Marco Asensio gave a night of high-class action the finale it deserved with a sensational solo goal to rub salt in Bayern wounds.
« The (red) card for Arturo 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. »
The German champions had been beaten on their previous four trips to Spain without even scoring a goal.
However, knowing they needed at least two to progress, Ancelotti’s men started on the front foot and were left to rue a huge opportunity just eight minutes in.
Marcelo made a miraculous block to deny Thiago Alcantara before former Real winger Arjen Robben scuffed into the side-netting on his trusted left foot.
Much like the first leg, Madrid weathered the early storm and had plenty of chances to go in front before half time.
Jerome Boateng bailed out a rare mistake from goalkeeper Manuel Neuer as he cleared off the line from Ramos after Neuer fumbled a simple cross.
The half-time whistle brought some respite to proceedings on the field, although the Bayern fans were involved in a minor clash with police at the break.
The disturbances quickly died down and Bayern soon gave the travelling 4,000 from Germany something to cheer when play resumed.
Another goal-line clearance by Marcelo from Robben’s dinked effort temporarily saved Madrid.
But the hosts didn’t escape moments later when referee Viktor Kassai pointed to the spot as Robben went down under a challenge from Casemiro.
Lewandowski stayed cool under the pressure and converted from the spot for his 39th goal of the season.
Ronaldo looked to have eased Madrid’s nerves when he steered Casemiro’s cross into the far corner 14 minutes from time.
However, Real’s celebrations were very short-lived as just a minute later the ball ricocheted around their box and Ramos turned into his own net.
The balance of a topsy-turvy tie turned Madrid’s way again with five minutes remaining as just as in the first leg, Bayern were reduced to 10 men when Vidal saw a second yellow card for chopping down Asensio.
The extra man proved decisive as Madrid settled the tie with a three-goal burst either side of half time in extra time.
Ronaldo took advantage at not being flagged for offside as he controlled and fired low past Neuer to become the first man to reach a Champions League century.
Four minutes into the second period of extra time he had Marcelo to thank for a brilliant run and unselfish pass that allowed the Portuguese the simplest of finishes to complete his hat-trick despite again being in an offside position.
And Asensio sealed victory in sensational style with a stunning solo run and low right-footed finish as many Bayern players sank to their knees knowing Champions League glory had passed them by for another year.