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 equaliser 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' defence.
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.
They were a whisker away from a goal when Xherdan Shaqiri and Arjen Robben combined well, with the Dutchman firing a cross-shot across the box, but Schweinsteiger failed to connect when he attempted to flick it past Bernd Leno.
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 they 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 their 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.
Stefan Kiessling crossed into the box, only for none of his team-mates to make challenge for the ball, but, for the most part, B04 were unable to find that bit of quality in front of goal, despite their promising build-up play.
Meanwhile, Bayern were 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 capitalised on some slack defending at the far post and tapped home.
Bayern charged up the other end of the pitch as they 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.