Arjen Robben struck in the 90th minute for Bayern to break the home side's collective heart, which extended Mainz's winless streak to nine matches.
While Bayern - typically - had 65 per cent possession, they only managed four shots for the match with the hosts producing three, and Mainz general manager Christian Heidel could not believe the home side ended the game without a point.
"It was a nice evening until the last minute. That was tragic," Heidel said, according to Bayern's website.
"No criticism of the team, they threw everything they had into it.
"Bayern have rarely been kept so far from the danger zone as today. The ball somehow slithered through at the end."
Coach Kasper Hjulmand explained he "tried everything" to spring a surprise, telling Mainz's website: "We started with a high pressing, with an early attack.
"Then we changed a bit, stood a little deeper, defended well.
"We had our opportunities. Toward the end, we were a bit tired.
"It hurts very much that we concede the goal in the last minute. It hurts to have received no reward for a good game."
The result left Mainz in 11th with 18 points ahead of the second half of the season, while Bayern (45 points) will enter the winter break on top of the table with a possible 14-point lead on second-placed Wolfsburg.
Mainz started strongly at the Coface Arena and deservedly hit the front in the 21st minute when Elkin Soto slid in at the back post to knock Pablo De Blasis' cross through Manuel Neuer's legs into the net.
But just three minutes later, Bayern were awarded what looked to have been a soft free-kick on the edge of the area and Bastian Schweinsteiger picked out the top corner of the net.
In the 90th minute, a rapid Bayern attack saw Franck Ribery release Thomas Muller down the left and he teed up Robben for the winner.
"We played very well," Soto said.
"We've given a very good account of ourselves but we head for home in despondent mood.
"We'd have really liked a point tonight. Now we have to go for it with everything we've got after the winter break."
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.