"It was a difficult game because we've come from Dortmund and Moscow," said Bayern coach Pep Guardiola, referring to his side's previous league and Champions League games.
"It's another game more and we won. In the end I'm very satisfied with the performance," the Spaniard added, after Bayern stretched its record unbeaten run to 39 games.
Dortmund found Mainz a tough nut to crack as Juergen Klopp returned to the club where he spent his entire playing career and coached for 7 years.
Pierre-Emerick Aubameyang finally broke the deadlock in the 70th, with a free kick that went in off the left post.
But Mainz equalized through Eric Maxim Choupo-Moting's penalty four minutes later after Lukasz Piszczek brought down Yanus Malli.
Robert Lewandowski restored Dortmund's lead through another penalty five minutes after that, and Mainz midfielder Elkin Soto was sent off for handling Aubameyang's effort on goal, before Lewandowski gave the scoreline a flattering look with another penalty in injury time.
"I'm totally happy with the result and with the way the game went," Klopp said.
Werder Bremen scored in the last minute for a 4-4 draw at Hoffenheim, Bayer Leverkusen beat relegation-threatened Nuremberg 3-0 and Hertha Berlin drew 0-0 with Augsburg.
Schalke defeated Stuttgart 3-0 in the late game to climb fifth and ease the pressure on coach Jens Keller.
"We played well here. It's crazy that it could end 3-0," said Stuttgart coach Thomas Schneider, whose side has just one win from its last seven games.
Jefferson Farfan scored in the 34th when Julian Draxler set him up on the right and claimed his second in the 47th from the penalty spot the seventh awarded in the Bundesliga on Saturday after Draxler made the most of Christian Gentner's contact to go down.
United States midfielder Jermaine Jones, who ran over 12 kilometers (7 1/2 miles) during the game, secured the result with a powerful shot inside the left post in the 79th.
"I have to pick one player out Jermaine Jones has taken criticism before, from me included, but he was outstanding today and I'm happy he got his goal," Keller said.
Earlier, Sejad Salihovic scored two penalties within six minutes for Hoffenheim to lead 2-0 by the 18th minute.
Bremen captain Aaron Hunt pulled one back in the 45th, also from the penalty spot, one minute before Eljero Elia equalized when Hunt's harmless-looking cross slipped through Koen Casteels' fingers.
Salihovic crossed for Kevin Volland to score four minutes after the break, and Kai Herdling made it 4-2 with a fine strike four minutes later.
But Nils Petersen pulled one back in the 59th and Philipp Bargfrede scored his first Bundesliga goal very late to secure an unlikely draw for Bremen.
"I'm happy for all the neutral fans and the journalists they enjoyed the game. For us coaches on the other hand, it would often make you tear your hair out," Bremen coach Robin Dutt said.
His counterpart was equally unappreciative.
"If we played normal games for the whole season, you could say that such a game is awesome," Hoffenheim coach Markus Gisdol said. "But it's like that every week with us. It's starting to get annoying."
Leverkusen, humiliated in Wednesday's 5-0 home defeat to Manchester United in the Champions League, remains four points adrift of Bayern after the side's 11th win from 14 games.
Sami Hyypia's side endured a difficult start against Nuremberg before Son Heung-min scored with a neat finish in the 36th, Jens Hegeler set up Stefan Kiessling with his heel two minutes after the break, and Son scored his second in the 76th.