The visitors took a shock lead courtesy of Karim Onisiwo’s close-range header midway through the first half.
Kingsley Coman’s confident finish from Corentin Tolisso’s pass restored parity, before Jamal Musiala completed the turnaround with a low strike.
Moussa Niakhate went closest to a late equaliser but shot straight at Manuel Neuer.
The result means manager Julian Nagelsmann has won 100 games in Germany’s top-flight, spanning spells with Hoffenheim, RB Leipzig and Bayern.
Nagelsmann’s side move six points clear of second-placed Borussia Dortmund, who were held to a 1-1 draw at Bochum.
Bochum’s Sebastian Polter opened the scoring from the penalty spot following goalkeeper Gregor Kobel’s foul on Christopher Antwi-Adjei, but Julian Brandt equalised late on from Erling Haaland’s cross.
Marius Wolf thought he had fired Dortmund level early in the second half, but Jude Bellingham was ruled to be in an offside position in the build-up to the goal.