Bastian Schweinsteiger belatedly broke the deadlock with just eight minutes to go before Mario Gotze sealed an 18th consecutive victory for Pep Guardiola's men
Pep Guardiola's men were made to work hard for the victory at the Coface Arena, with Bastian Schweinsteiger and Mario Gotze scoring two goals in the last 10 minutes as the Bavarians racked up an 18th straight league triumph.
However, Bayern will have to wait for at least another round before they can be crowned champions as second-placed Borussia Dortmund and Schalke, who sit third, both won.
Bayern remain 23 points clear of Dortmund, who beat Hannover, with Schalke a further point behind following their success against Eintracht Braunschweig.
The first-half failed to yield much in terms of goalmouth action as Bayern were met by a stubborn Mainz defence, while Christian Heidel's charges were keen to break quickly on the counterattack.
Eric Maxim Choupo-Moting went close to putting Mainz ahead shortly after the break with an effort that cannoned against the crossbar.
Goalkeeper Loris Karius then made a string of fine saves to frustrate the visitors, but there was nothing he could do to prevent Schweinsteiger's free header in the 82nd minute, before Gotze added a second with a close-range finish.
Bayern showed their intent as early as the fourth minute when Christoph Moritz's poor headed clearance fell kindly for Arjen Robben but his right-foot shot was beaten away by goalkeeper Loris Karius.
Mainz responded well, however, and their willingness to attack quickly on the break yielded arguably the best chance of the opening exchanges as Nicolai Muller cut inside David Alaba from the right only to shoot tamely at Manuel Neuer.
The visitors began to predictably control possession, though Mainz's resolute defence continued to frustrate Bayern.
It took until the 35th minute for Bayern to test Karius again, Robben once more the architect as he created space to send a curling shot straight at the goalkeeper.
A rare Mainz attack came to nothing eight minutes before the interval when Shinji Okazaki was flagged for offside as he raced on to Park Joo-Ho's long pass before striking the post.
Bayern were searching for greater penetration in the final third after the break, but Guardiola's men survived a huge scare in the 47th minute when Choupo-Moting charged at Philipp Lahm before unleashing a fierce strike that beat Neuer but crashed off the underside of the crossbar.
At the other end Mainz were thankful to Karius for keeping the scores level as Mario Mandzukic leapt to meet Alaba's cross and his powerful header seemed destined for the top corner but the keeper produced a superb stop.
Bayern's attacking improvement continued just after the hour mark with Robben once again teasing the Mainz defence and forcing Karius into a low near-post stop.
Karius was proving to be essential in Mainz's plucky resistance, the goalkeeper making a fine stop with his left leg to deny Franck Ribery's strike across the face of goal with just under 20 minutes remaining.
Bayern finally made the breakthrough with eight minutes left as Xherdan Shaqiri's superb cross was headed home by Schweinsteiger at the back post.
Cruelly for Mainz, Gotze added a second in the 86th minute, the Germany international keeping his composure to slide past Karius.