Cristiano Ronaldo’s injury-time penalty put holders Real Madrid through to the Champions League semi-finals after holding off a stunning Juventus comeback.
Ronaldo’s coolly taken 97th-minute penalty into the top corner came after Medhi Benatia brought down Lucas Vazquez in the box.
Juve goalkeeper Gianluigi Buffon, in what might be his last Champions League appearance, was sent off by English referee Michael Oliver after awarding the spot-kick, for foul and abusive language.
Real, Champions League winners in three of the past four seasons, came into the second leg leading 3-0, helped by Ronaldo’s stunning bicycle kick.
But the Serie A leaders got off to a perfect start when Mario Mandzukic headed in from Sami Khedira’s cross after just two minutes and Mandzukic got a second before half-time.
Blaise Matuidi pounced to capitalise on Keylor Navas’ fumble to level the tie on aggregate before the dramatic ending.
Real join Liverpool, Roma and Bayern Munich in the last-four draw, which takes place in Nyon on Friday at 12:00 BST.
The game looked to be heading for extra time before a chaotic final few minutes saw even the calmest of players lose control.
Real have endured a poor season so far in La Liga, sitting fourth in the table and 15 points adrift of runaway leaders Barca, who capitulated on Tuesday night to go out of the Champions League.
The competition is Real’s only hope of a major trophy this season, but they only just managed to sneak through to the last four for the eighth consecutive season.
Bayern Munich ground out a 0-0 draw to see off Sevilla’s spirited challenge and reach the Champions League semi-finals with a 2-1 aggregate win.
The newly crowned German champions, who won their past two home games 6-0, needed defensive grit to match their usual attacking flair at a sold-out Allianz Arena.
Sevilla defender Joaquin Correa, who was sent off in stoppage time, hit the bar with a header and midfielder Pablo Sarabia, who scored in the first leg, wasted a glorious first-half chance.
But Bayern top-scorer Robert Lewandowski had a header pushed over the crossbar by goalkeeper David Soria and a brilliant block from Sevilla’s Jesus Navas denied Franck Ribery.
It was the first time in 22 home Champions League matches that Bayern had failed to score.
Sevilla defender Gabriel Mercado, replacing injured centre-back Simon Kjaer, was lucky to stay on the pitch after bringing down Lewandowski when he split the visiting defence in the second minute.
But Vincenzo Montella’s side recovered to control the first half, even if they were ultimately frustrated, none more so than Correa, who slid in wildly on Javi Martinez to earn a red card.
Bayern – into the semi-finals for the seventh time in nine years – join Liverpool, Roma and Real Madrid in the draw, which takes place in Nyon, Switzerland, at 12:00 BST on Friday.