Joshua Kimmich, Niklas Sule, Leroy Sane and Robert Lewandowski all got on the scoresheet in the second half to undo an impressive first-half performance from the visitors.
Bayern Munich have made a habit of conceding the first goal and against Mainz, the Bundesliga champions fell behind as well. Earlier, Manuel Neuer was forced into making a save in the fifth minute.
Just three minutes later, Neuer's opposite number, Finn Dahmen also prevented Leroy Sane's deflected shot from crossing the line. Chances came aplenty for both sides in the first half-hour of the game but the decisive touch in the box was missing.
Corentin Tolisso shot straight at the goalkeeper when he was found inside the box at the end of a quick-transition move. Bayern Munich were made to regret not converting their half chances as Jonathan Burkardt opened the scoring with a wonderfully struck shot in the 32nd minute, following a break.
The visitors certainly had the better opportunities in the first half but the hosts also upped their ante as the half-time whistle approached. Burkardt was again involved in the buildup to Mainz's second goal, as he earned the foul that allowed the Bundesliga strugglers to double their lead from the following free-kick via Alexander Hack's bullet header.
After the break, the hosts had only one thing on their mind and that was to record yet another Bundesliga win. Within 10 minutes after the restart, they were already level, with Joshua Kimmich and Leroy Sane scoring in the 50th and 55th minute respectively.
Bayern Munich were denied a third goal by the VAR in the 66th minute but took the lead four minutes later through substitute Niklas Sule's volley.
Lewandowski also got on the scoresheet as he converted a 76th-minute penalty and added a second in the 82nd minute to put the game beyond the visitors' reach.
It was one of the most entertaining games in the Bundesliga this season but one that ended in a familiar sight with Bayern Munich taking the three points at the end of the 90 minutes.
Here are the five major talking points from the game as the Bavarians go atop the Bundesliga standings.
#5 Bayern Munich concede first for the eighth consecutive Bundesliga game
Bayern Munich made history in 2020 for all the right reasons but started 2021 by registering an unwanted record as they ended up conceding the first goal in the Bundesliga for the eighth game running.
It's the first time in the German top-flight history that the Bavarian giants have gone 1-0 down for eight back-to-back fixtures.
Although it has not prevented the reigning champions from recording wins in the league, they went two goals behind without a reply in the first half against Mainz and that's not how Hansi Flick would've expected his Bayern Munich team to perform in the first game of the year.
They showed steely determination to secure a memorable comeback win but conceding first consistently does not bode well for them.
#4 Mainz's inspired first-half display caught the hosts by surprise
Despite only having 30% possession in the first 45 minutes, Mainz found themselves two goals ahead of Bayern Munich at the Allianz Arena and all things considered, it was a well-deserved lead for Die Nullfünfer.
They matched the hosts shot-for-shot in the first half and even had the first shot on goal. Mainz were very clinical in the final third and from their eight attempts on goal, six were on target.
The attacking duo of Robin Quaison and Jonathan Burkardt made the most of Bayern's high press and at times, found themselves with ample space in dangerous positions.
But Bayern Munich scored five times after the break to move atop the Bundesliga standings.