The Werkself appeared to have earned a draw against the Bavarians through Simon Rolfes' strike, but the former Nurnberg defender put through his own net late on
Mario Gomez had given the visitors the lead just before the break, but the hosts regrouped in the second half and grabbed a deserved equalzer through Simon Rolfes, only for Philipp Wollscheid to score an own goal three minutes from time.
When the match started, neither side managed to take command. Andre Schurrle had a brief opening ofter a poor Dante pass, but failed to make the most of it, while Bayern peppered the Leverkusen box with crosses, none of which duly threatened the hosts' defense.
Eventually, though, Jupp Heynckes' side began to exert more and more pressure. Bastian Schweinsteiger drove wide from just outside the box when he should have done better, while Gomez skewed an effort over the bar after some great work from Alaba down the left.
Luiz Gustavo had a header cleared off the line by Gonzalo Castro after meeting a corner at the near post, while Robben fired an effort over in customary fashion after picking up a loose Dani Carvajal pass as Bayern pressed for an opener, ultimately in vain.
At the other end, Leverkusen had offered very little. Stefan Kiessling had muted appeals for a penalty turned down after a challenge from Jerome Boateng, while Sebastian Boenisch had a good drive saved by Manuel Neuer from distance.
Eventually, though, a moment of brilliance broke the deadlock. Gomez took a Shaqiri pass in his stride, superbly chipped the ball over Carvajal, and sent a great shot past Leno, and Bayern had its lead just before the break.
In an attempt to get back into the game after the restart, Leverkusen brought on Sidney Sam, and the 25-year-old almost had an impact, shooting over after Bayern failed to clear a corner.
Meanwhile, Bayern was looking more incisive on the break. Shaqiri should have double the lead after being set up by some wonderful Robben skill, while Gomez failed to get the ball out of his feet under pressure from Boenisch.
Heynckes elected to try and preserve the lead, bringing Daniel Van Buyten on for Robben, but the ploy soon backfired. Boenisch met a corner at the near post and headed it onto Rolfes, who capitalized on some slack defending at the far post and tapped home.
Bayern charged up the other end of the pitch as it looked for a winner, but Pizarro and Alaba both saw shots charged down before the Peruvian dragged wide.
The winner arrived in miraculous fashion soon after, with Schweinsteiger floating in a free kick which struck Wollscheid and bounced into the net.