MADRID — Imagine a mob of people, thousands of them, standing outside an old wooden door. First the members of the pack take turns banging on the door. Then the banging turns to kicking. And then the kicking turns to pounding, as body after body rams ahead only to return with little more than an aching shoulder.

That was the last 20 minutes of the Champions League semifinal match here on Wednesday night. Real Madrid, the defending European champion, needed a goal, another goal, however it could find one. Juventus, the Italian champion, needed only to avoid having its dreams kicked in.

The result was a magical finish as the shots came from all sides, all angles. Crosses were sprayed into the penalty area as if from a hose. A header from close range went over the net. A near-post effort went to the wrong side of the stick. A blast from straight on was deflected into little more than a dribble. The home fans, 75,000 strong, shrieked for more and more and more.

Medhi Benatia, left, the Moroccan defender for Bayern Munich, and Barcelona’s Javier Mascherano, an Argentinian defender, during Tuesday’s second-leg game.Bayern Munich 3, Barcelona 2: Barcelona Ushers Resigned Bayern Munich Out of Champions LeagueMAY 12, 2015
Carlo Ancelotti, Real Madrid's coach, may find his job in jeopardy if his team is eliminated from Champions League play by Juventus.Live and Kicking: Soccer Games to WatchMAY 11, 2015
But the door held. And when the game was over and the referee had blown his whistle, Gianluigi Buffon, Juventus’s goalkeeper and captain and the centerpiece of a defensive effort that will go down in his club’s grand history, raised his arms and danced toward his teammates with a smile that stretched to the stadium’s upper deck.

Real Madrid's Cristiano Ronaldo scored once in the first half but missed on several opportunities in the second half. Credit Daniel Ochoa De Olza/Associated Press
There will be no Clásico in the Champions League final, but there will be an Old Lady: Juventus, whose colorful nickname is matched only by its colorful fans. The club upset the prospect of an all-Spanish title game by stifling Real Madrid in a tense, tingling 1-1 tie, which, coupled with a 2-1 victory in Turin, Italy, last week, gave Juventus a 3-2 aggregate victory in the two-game series. The team will play for the championship on June 6 in Berlin against Barcelona, which eliminated Bayern Munich on Tuesday.

Juventus will be there what it was here: an underdog. But with a few key attackers and a proven ability to showcase the traditional Italian catenaccio, or door bolt, in defense, the club will have designs on another upset.

“We will not be tourists in Berlin,” Buffon said. “When you have the chance to play a Champions League final, you have to win it.”

Juventus has that opportunity because of Álvaro Morata, a midfielder who signed with the team after Real Madrid let him go last season. Morata scored in the first leg and, on Wednesday, provided the decisive goal in the 57th minute, when he chested down a looping header from Paul Pogba and lashed a shot past Madrid goalkeeper Iker Casillas.

Morata did not celebrate his goal against a former club (as per a soccer tradition), but he was the only one rooting for Juventus who did not; on the sideline and in the stands, where a few thousand visiting fans were massed together in the highest tier, the histrionics were memorable.

“We can’t stop dreaming,” Morata said afterward.

Cristiano Ronaldo and his Madrid teammates, on the other hand, looked ashen. Their 1-0 lead would have been enough for them to advance because away goals serve as a tiebreaker, but Morata’s score jarred them toward an unpleasant reality. For a club with a payroll as astronomical as Madrid’s, expectations are always absurdly high, and this season — with the Spanish League title all but lost to Barcelona, the Copa del Rey out of reach and the Champions League trophy now unattainable — can be seen as nothing short of a disappointment.
Carlo Ancelotti, the team’s coach, had already been rumored to be on the hot seat; this elimination figures only to increase the speculation that Madrid’s president, Florentino Pérez, will make a change.

“It’s not up to me to talk about my future,” said Ancelotti, who led Madrid to its 10th European title last year in Lisbon. “I’d like to stay here. But I know very well how football is.”

Many Madrid fans will say they saw this coming. Unlike Tuesday’s game — Barcelona entered its second leg with a three-goal lead and was never in real danger of losing it — Wednesday’s had some measure of doubt for Spanish supporters as afternoon rolled toward evening. The visiting Juventus fans were rowdy and brash — they had several clashes with the police before kickoff — and one Madrid supporter, standing at a cafe not far from the stadium, nicely encapsulated a common worry when he said, “We are in trouble because they have a tremendous goalkeeper, and we have a terrible one.”

While that may have been overstating it, there was no question that criticism of Ancelotti and his players, particularly Casillas, had grown in recent weeks.

A longtime goalkeeper for Madrid (and Spain’s national team), Casillas has recently been targeted by a large contingent of his own team’s fans with whistles and boos. Last weekend, when he was jeered during a match against Valencia, he was caught by television cameras uttering an insult at his hecklers.

On Wednesday, though, he was hardly the problem. Casillas made a number of saves — including a point-blank stop on Pogba that kept alive Madrid’s chances — while his teammates struggled to produce the explosiveness that a group featuring Cristiano Ronaldo, Gareth Bale and Toni Kroos ought to offer.

Bale finished the night with seven shots, only one on target; Ronaldo had three shots, with only his first-half penalty kick, on which he scored, ending up on goal. The performance was, in many ways, a continuation of last week’s tepid output.

“Defeats and errors help you improve,” Sergio Ramos, a Madrid defender, said. “They teach you. And if you don’t learn your lessons, you get punished.”