Elkin Soto gave the Westphalians a fright with a goal after just 52 seconds, but Neven Subotic and Marco Reus turned things around in five second-half minutes.
Yunus Malli brought Mainz back on terms almost instantly, but Pierre-Emerick Aubameyang and Nuri Sahin gave coach Jurgen Klopp victory against his former club and lifted Dortmund out of the Bundesliga relegation zone, at least for a night.
The game could not have started much worse for Dortmund, who were behind within a minute.
Shinji Okazaki was beaten by Dortmund goalkeeper Roman Weidenfeller’s punch, but the ball fell to Soto, who lobbed it back from 25 yards with Marcel Schmelzer unable to clear it off the line.
Dortmund’s response was instant, but after Reus hit the post and Shinji Kagawa was denied by Mainz keeper Stefanos Kapino, who also made a save from Aubameyang, it started to look like it was going to be another frustrating night for Klopp and co.
That changed five minutes into the second half when Subotic headed an outswinging corner beyond Kapino’s reach to bring the hosts level.
It was then down to the duo Dortmund are pinning their hopes on delivering their next period of success to put them in front.
Winter signing Kevin Kampl, earmarked to fill the void left by Mario Gotze, threaded the ball through to Reus, who this week signed a new contract until 2019, and he skipped past Kapino before scoring his eighth career goal against Mainz.
The joy was short-lived, though, with Mainz replying within two minutes.
Malli let the ball slide across onto his right foot, and he fired his shot past Weidenfeller into the top right-hand corner, prompting the Westfalenstadion to fall silent for the second time.
Their fears were allayed by Aubameyang in the 71st minute, however, when he restored Dortmund’s lead with two deft touches from Reus’ pinpoint delivery and, seven minutes later, Sahin pounced after Aubameyang’s free-kick was saved to put the result beyond doubt.
Dortmund’s fans were able to breathe a sigh of relief, but conceding two goals at home and gaining the upper hand only in the final 20 minutes shows there is still a long way to go before Dortmund can count themselves safe, although it was at least another step in the right direction.