Bundesliga: Bayern Munich 4 Mainz 1
The European champions' 33-game unbeaten run in the Bundesliga looked to be under threat when Shawn Parker gave Mainz a shock half-time lead.
But coach Pep Guardiola brought on midfielder Mario Gotze at half-time and the Germany international inspired a second-half fightback.
Gotze laid on goals for Arjen Robben and Mario Mandzukic, and Thomas Muller scored twice to ensure Bayern are now just two games away from levelling the Bundesliga's longest unbeaten run, held by Hamburg.
Bayern wingers Franck Ribery and Xherdan Shaqiri missed the match through ankle and hamstring injuries, while defender David Alaba dropped to the bench.
Robben, Mandzukic and Diego Contento came into Bayern's side, while Mainz made six changes to the team that drew with Hoffenheim before the international break, with goalkeeper Christian Wetklo the headline inclusion.
Mainz came into the match without a win in their last five, but they set about frustrating Bayern and showed some attacking threat, with Johannes Geis firing over the bar with his left foot in the 12th minute.
Bayern lost Brazil defender Dante to injury with half-time looming and they were stunned moments later, falling behind after Parker capitalised on a Jerome Boateng error.
The defender missed Julian Baumgartlinger's routine ball through the middle and Parker raced clear, rounding Bayern goalkeeper Manuel Neuer before slotting into an empty net.
Gotze entered the fray at the break in place of Rafinha and that proved to be an inspired move as the midfielder made an instant impact.
The former Borussia Dortmund man cut open the Mainz defence with a through ball to Robben just four minutes after the break and the Holland winger equalised with a measured left-foot finish inside the near post.
And Bayern were in front just two minutes later, with Robben turning provider on this occasion.
Robben laid the ball off to Muller and the Germany forward kept his composure, slotting past Wetklo from the centre of the penalty area.
Mainz were struggling to live with Guardiola's men and the home side gave themselves breathing space in the 69th minute, with Gotze the architect once again.
Gotze got to the byline and cut back for Mandzukic, with the Croatia striker shooting into the far corner, before Muller put the icing on the cake with eight minutes to play.
This time it was from the penalty spot, after Junior Diaz fouled Bastian Schweinsteiger, and Muller converted to cap off Bayern's excellent second half.