The match was decided from the spot following a 3-3 aggregate scoreline after extra time.
Madrid were awarded a penalty in the fourth minute of normal time when David Alaba was adjudged to have handled in the area. Cristiano Ronaldo calmly slotted the ball past Manuel Neuer to put his side ahead.
Alaba almost made amends minutes later when he crossed for Arjen Robben, but the Dutchman somehow put the ball over from six yards.
Munich were on the attack soon after as Mario Gomez's stinging effort was pushed away by Iker Casillas into the path of Franck Ribery, who put the rebound wide.
The hosts were 2-0 in front on the night after 14 minutes when Ronaldo fired past Neuer following Mesut Ozil's pass.
Despite Madrid's lead, Bayern continued to pose a threat on the break as demonstrated when Gomez fired wide.
The Germans levelled the aggregate scores on 26 minutes as Robben squeezed the ball past Casillas from the penalty spot after Pepe had dragged down Gomez when challenging for the ball.
The persistent Gomez should have done better when he fired straight at Casillas shortly after, while Ronaldo tried his luck again from a free kick that was gathered by Neuer.
There was one last chance of the half for Robben, but his free kick was parried away by Casillas.
Where the first period was one of attacking intent from both sides, the second saw a more cautious approach as both teams were fearful of conceding what would have been a telling goal.
Karim Benzema forced a good save from Neuer on the angle before Ronaldo's free kick went straight at the goalkeeper.
The Portuguese forward blasted another set piece over, while Robben was thwarted by the onrushing Casillas to stop a rare Bayern attack.
The visitors nearly snatched it in the dying minutes of normal time, but Gomez dwelt on the ball too long before poking a weak shot at Casillas.
There was little to separate between the teams during the first half of extra time, with Sergio Ramos nearly getting on the end of a corner during a brief period of Madrid pressure.
The hosts had most of the play in the second half, but they were unable to create any clear openings as the game went to penalties.
Ronaldo and Kaka both had their kicks saved as Munich raced into a 2-0 lead in the shootout. Alonso's goal coupled with Lahm's and Kroos's saved efforts then gave Madrid the chance to level things up, but Ramos fired well over the bar.
Bastian Schweinsteiger gave his side a 3-1 win from the spot when he calmly converted.
The Bundesliga club will face Chelsea at their own Allianz Arena on Saturday, May 19.