Match ends, Real Madrid 4, FC Bayern München 2.
Cristiano Ronaldo scored a hat-trick to take his Champions League tally to 100 goals as holders Real Madrid controversially overcame Bayern Munich in extra time to reach the semi-finals.
Bayern Munich midfielder Arturo Vidal's harsh 84th-minute dismissal was the first pivotal moment of a thrilling game, and Ronaldo was clearly standing in an offside position to score Madrid's second in extra time.
Needing at least two goals to progress, Bayern had led when Robert Lewandowski confidently drilled in a penalty.
Madrid struggled to find rhythm at a nervy Bernabeu before Ronaldo headed in Casemiro's precise cross.
Bayern responded just 36 seconds later as Sergio Ramos' own goal forced extra time, but then crumbled after Ronaldo fired in Madrid's second.
The Portugal captain tapped in the third - his 100th Champions League goal - after Marcelo's marauding run, with Marco Asensio sealing victory by shooting into the bottom corner.
Madrid will discover their semi-final opponents when the draw is made on Friday.
Neighbours Atletico progressed after edging past Leicester City, while the other two ties - Barcelona against Juventus, and Monaco against Borussia Dortmund - conclude on Wednesday.
Bayern see red in controversial exit
Anticipation was high when two of Europe's biggest and most successful clubs were drawn together - and an enthralling tie did not disappoint.
However, it was somewhat tinged by Madrid benefiting from two debatable decisions by Hungarian referee Viktor Kassai and his officials.
Chile midfielder Vidal, already booked for an early foul on the edge of the Bayern area, was shown a second yellow card for what appeared to be a clean sliding tackle on Madrid substitute Asensio.
And then Ronaldo was standing at least a yard offside when he met Ramos' pass and spun to fire Madrid 4-3 ahead on aggregate.
"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," Bayern manager Carlo Ancelotti said.
Nothing separated the two teams over 180 engaging minutes in Munich and Madrid, only for the German champions to finally run out of steam as they battled a numerical disadvantage.
Bayern also played the final 30 minutes at the Allianz Arena last week with 10 men after Javi Martinez's dismissal.
Ancelotti's side remained resolute in the first period of extra time - until the tiring visitors unravelled after Ronaldo put the Spanish league leaders ahead.
History-seeking Madrid get the rub of the green
Madrid are aiming to become the first club to retain the Champions League and moved a step closer by eventually seeing off Bayern.
For long periods, Madrid were edgy defensively and uncertain going forward - with Ronaldo guilty of wasting a number of chances in normal time.
Bayern knew they would have to become only the third side to overturn a first-leg home defeat in a Champions League tie to reach their sixth successive semi-final.
Fewer places are harder to achieve that than the home of the 11-time European champions.
Although only one away team had managed to leave the Bernabeu with victory in Madrid's previous 33 home matches in all competitions, Bayern looked confident and organised as they quietened the home crowd.
Bayern top scorer Lewandowski, who missed the first leg with a shoulder injury, fired them ahead with a coolly taken penalty before Ramos' bizarre own goal - the ball ricocheting off his right foot and spinning inside the near post - forced extra time.
But Madrid eventually wrestled control of the tie thanks to their numerical advantage and the decisions of the officials.
Sheer relief greeted the final two Madrid goals as their jubilant players wildly celebrated reaching a record seventh successive semi-final in Europe's premier club competition.
"I don't get involved if decisions are right or wrong," said Madrid manager Zinedine Zidane.
"Everyone has their own opinions, some might say it was not a second yellow card for Vidal, some might say it is.
"Cristiano's goal might have been offside but it doesn't change anything."
'Ronaldo is always there for us' - post-match reaction
Madrid manager Zinedine Zidane:
On some home supporters whistling at Cristiano Ronaldo during the game: "Cristiano has shown that in the key moments he is there, he makes the difference. When he has to be, he is there.
"It is unique and we are happy for him and for the team.
"Maybe after today they do not whistle anymore, but this is Madrid and that things happen from time to time, and he knows it. He has to be calm.
"The public will always thank Cristiano for everything he has done."
- Cristiano Ronaldo's hat-trick made him the first player to reach 100 Champions League goals
- On the same night, Real's neighbours Atletico reached the same tally as a club
- Madrid have qualified for the Champions League semi-finals for the seventh consecutive season - the longest streak in competition history
- Bayern lost both legs of a Champions League knockout tie for the first time since April 2014, which was also against Real Madrid in a 5-0 semi-final aggregate defeat
- Ronaldo has scored nine times against Bayern in the Champions League - only Barcelona's Lionel Messi has scored as many against a single opponent (against Arsenal)
- Lewandowski has netted six goals against Real Madrid in the Champions League, the most of any opposition player
- The Poland striker converted his sixth penalty in the Champions League, maintaining his 100% record from the spot in the competition (excl. shootouts)
- Arturo Vidal's red card was the 19th shown to a Bayern Munich player in the Champions League - only Juventus (22) have had more in the competition
- The average age of Bayern's starting line-up in this game was 30 years and 116 days, making it their oldest in Champions League history
Both teams go back to domestic league action hoping to move a step closer to their respective titles.
Madrid have the small matter of El Clasico to focus on. Zidane's team can move six points clear at the top of La Liga by beating arch-rivals Barcelona.
The sides meet on Sunday at the Bernabeu (19:45 BST), with live text commentary on the BBC Sport website.
Bundesliga leaders Bayern, who are eight points clear with five games left, will hope to bounce back from this defeat when they host Mainz on Saturday.
- 14CasemiroBooked at 40mins
- 8KroosSubstituted forKovacicat 114'minutes
- 22IscoSubstituted forVázquezat 71'minutes
- 9BenzemaSubstituted forAsensioat 64'minutes
- 7Cristiano Ronaldo
- 5HummelsBooked at 75mins
- 14AlonsoBooked at 70minsSubstituted forMüllerat 75'minutes
- 10RobbenBooked at 101mins
- 23VidalBooked at 84mins
- 6Thiago Alcántara
- 7RibérySubstituted forDouglas Costaat 71'minutes
- 9LewandowskiSubstituted forKimmichat 88'minutes
- 11Douglas Costa
- 13Ferreira de Souza
- Viktor Kassai
- Shots on Target
Second Half Extra Time ends, Real Madrid 4, FC Bayern München 2.
Attempt missed. Casemiro (Real Madrid) right footed shot from the right side of the box is high and wide to the left. Assisted by Marcelo.
Attempt missed. Mats Hummels (FC Bayern München) header from the centre of the box misses to the left. Assisted by Arjen Robben with a cross following a set piece situation.
Arjen Robben (FC Bayern München) wins a free kick on the right wing.
Foul by Mateo Kovacic (Real Madrid).
Substitution, Real Madrid. Mateo Kovacic replaces Toni Kroos.
Foul by Douglas Costa (FC Bayern München).
Lucas Vázquez (Real Madrid) wins a free kick in the defensive half.
Goal! Real Madrid 4, FC Bayern München 2. Marco Asensio (Real Madrid) right footed shot from the centre of the box to the bottom left corner following a fast break.
Goal! Real Madrid 3, FC Bayern München 2. Cristiano Ronaldo (Real Madrid) right footed shot from the centre of the box to the centre of the goal. Assisted by Marcelo.
Corner, FC Bayern München. Conceded by Nacho.
Attempt missed. Casemiro (Real Madrid) right footed shot from outside the box misses to the left. Assisted by Lucas Vázquez.
Second Half Extra Time begins Real Madrid 2, FC Bayern München 2.
First Half Extra Time ends, Real Madrid 2, FC Bayern München 2.
Goal! Real Madrid 2, FC Bayern München 2. Cristiano Ronaldo (Real Madrid) left footed shot from the centre of the box to the centre of the goal. Assisted by Sergio Ramos.
Foul by Mats Hummels (FC Bayern München).
Keylor Navas (Real Madrid) wins a free kick in the defensive half.
Corner, FC Bayern München. Conceded by Daniel Carvajal.
Offside, Real Madrid. Lucas Vázquez tries a through ball, but Cristiano Ronaldo is caught offside.