Nicolai Muller scored the first and the last goal of the game for Mainz with Artur Sobiech and Mame Diouf turning things around in between.
Hannover ended the game with 10 men following a red card for Christian Schulz, and they look likely to have ended their hopes of qualifying for the Europa League in the process.
Three points still separate them from Freiburg in sixth, but they have a game in hand against struggling Augsburg tomorrow.
Both sides have recently seen their European qualification hopes disintegrate, but that did not mean they had nothing to play for at the Niedersachsenstadion.
Fresh from a 3-2 win over Greuther Furth last weekend, the hosts began confidently with Jan Schlaudraff lifting a ball in for Diouf, but he fouled Bo Svensson in trying to win the header.
Mainz were happy to leave the ball to the Reds and try to force the kind of mistake which allowed them to take the lead in the 25th minute.
Schlaudraff's sloppy pass went straight to Muller, who touched the ball through the legs of Karim Haggui and then beat Ron Robert Zieler with a composed finish.
Schlaudraff felt the fans' frustration when he gave possession away easily once again moments later, but he made amends by setting up the equaliser in the 36th minute.
His cross was met by Sobiech, who had come on just a minute earlier to replace the injured Mohammed Abdellaoue and who rose higher than anybody to head in from six yards out.
Muller scored again in the 40th minute, but rather than celebrating a goal, he was shown a yellow card for deliberate handball as he touched the ball past Christian Wetklo with his arm.
Hannover increased the pressure in the second half, although their hopes of finding a winner were dashed when Schulz picked up a second yellow card in the 65th minute.
That did not stop the Reds, though, and they went in front in the 70th minute through Diouf.
Sobiech sent the Senegalese striker through on goal and he kept his cool to pick his spot in the left-hand corner.
Zieler preserved Hannover's lead in the 78th minute with a fine save from Scott Parker, but he was beaten a minute later by Muller, who shot in low from a tight angle from Parker's pass.
Hannover had the last chance of the game in the 90th minute, but Diouf wasted the opportunity and, with it, probably their chances of a third straight season in the Europa League.