Pierre Aubameyang put the visitors in front in the 70th minute, but Eric-Maxim Choupo-Moting soon levelled for the hosts, who had been unlucky to fall behind.
Their fortune then took another turn for the worse when Elkin Soto kept Lewandowski's goalbound shot out with his hand, earning a red card before the Pole converted.
Lewandowski then scored again from the spot to clinch the victory with his 10th goal of the campaign.
Mainz headed into the game having recently picked up form and moved to the fringes of the top six, and they appeared keen on inflicting a third straight defeat on Dortmund.
Zdenek Pospech and Johannes Geis both tested Roman Weidenfeller, who dealt with the shots with varying degrees of conviction before looking more comfortable to keep out Shinji Okazaki's acrobatic effort.
Lewandowski wasted a rare chance for Dortmund, whose coach Jurgen Klopp soon made an adjustment to his side by introducing Nuri Sahin for Sven Bender.
Even after altering their tactics, the visitors still spent much of the time chasing the ball as Klopp's former club gave them the runaround at the Coface Arena.
Klopp made two more changes at the interval with Henrikh Mkhitaryan and Sebastian Kehl brought on for Marco Reus and Jakub Blaszczykowski, yet Mainz continued to cause the greater problems with Choupo-Moting sending a shot just beyond the far post.
Dortmund then took the lead against the run of play when Aubameyang sent an unstoppable free-kick into the top-left corner from 25 yards.
The first penalty of the game went Mainz's way when Lukasz Piszczek blocked Yunus Malli inside the penalty area, and Choupo-Moting beat Weidenfeller from 12 yards.
Parity lasted only four more minutes before Lewandowski rounded Loris Karius, but Soto reached out with his hand to turn the Pole's shot behind.
He was shown a red card and Lewandowski was given another chance to score, and he took it.
Lewandowski then sealed the triumph after being brought down by Karius inside the area, scoring his second penalty of the afternoon with the last kick of the game.