Mario Gomez put Jupp Heynckes' side in front, but they needed a rather fortunate own goal from Philipp Wollscheid to win the game late on after Simon Rolfes had brought the hosts level.
The win restores Bayern's 20-point cushion at the top of the table with only eight games of the season left while Leverkusen now trail second-placed Borussia Dortmund by four points and remain six clear of Eintracht Frankfurt and Schalke in fourth.
Bayern played with a weakened side as Heynckes gave rests to captain Philipp Lahm, Franck Ribery, Thomas Muller and Mario Mandzukic.
Gomez was chosen to lead the attack, and he put Bayern in front in the 37th minute, taking Xherdan Shaqiri's pass down on his chest before beating Sebastian Boenisch and poking the ball past Bernd Leno.
It was a deserved lead for the visitors after Arjen Robben and Jerome Boateng had also gone close.
Sidney Sam, whose goal decided affairs at the Allianz Arena, was sent on by Bayer's joint coaches Sami Hyypia and Sascha Lewandowski, and he gave the hosts a boost with a shot which tested Manuel Neuer and gave the home team belief.
They drew level in the 75th minute when Rolfes arrived at the far post to head in Gonzalo Castro's corner, which had been nodded on by Boenisch.
It looked like it would be enough to earn Leverkusen a draw, but when Wollscheid unwittingly diverted Bastian Schweinsteiger's free-kick into his own goal, Bayern's 22nd win of the season was completed, leaving them just four points away from sealing the title.