Bayern keeper Manuel Neuer was the hero of the night, saving spot-kicks in the shootout from Cristiano Ronaldo, who had given Real a 2-0 lead early in the game, and Kaka before Bastian Schweinsteiger struck the decisive penalty.
Video clip of the penalty kicks
Bayern showed considerable nerve to get back into the match after conceding twice in the first 14 minutes and Arjen Robben levelled to make the score 3-3 on aggregate.
A pulsating first half with chances for both sides fell away after the break.
"It was a magnificent game and great penalty shootout," a beaming Bayern coach Jupp Heynckes told reporters.
"We didn't want the first 15 minutes, to concede one and then two goals especially here because everyone knows what it is like, but after that I think we dominated. Over the 120 minutes I think we deserved it."
The Germans denied Real a crack at a record 10th European Cup and will meet Chelsea at the Allianz Arena on May 19th, after they stunned holders Barcelona on Tuesday 3-2 on aggregate.
Real keeper Iker Casillas kept Real hopes alive by saving efforts from Toni Kroos and Philipp Lahm in the shootout but Sergio Ramos skied his penalty over the bar and Schweinsteiger rifled the Bavarians through.
"I have not witnessed something like that in 40 years of professional football," said Bayern CEO Karl-Heinz Rummenigge.
"This tops everything we experienced in the 70s and 80s. I am very happy and very proud. That was top quality football."
The home side had quickly cancelled out Bayern's 2-1 first-leg win when Ronaldo netted a sixth-minute penalty after a handball in the area and then produced a smart finish from the edge of the area eight minutes later.
Bayern pulled a goal back in the 27th minute when Arjen Robben also netted from the spot after Mario Gomez had been bundled over by Pepe.
After the break, both sides were more cautious but with extra time approaching Gomez squandered a chance to send Bayern through when he took too long to control and Khedira was able to get back and smother his weak shot.
Extra time was draining on Real, who had all but wrapped up La Liga with a 2-1 win at Barca on Saturday, and that tiredness proved costly at the end.
"I will lift my players appealing to their pride, I have nothing to reproach them for." Real coach Jose Mourinho said.
"They have given their all. If the club and the players think I and they can keep bringing something to this. I will continue"