Ten-man Mainz moved into the top six of the Bundesliga, dislodging opponents Hannover with a spirited win at the Coface Arena.
Thomas Tuchel's men took the lead through Nicolai Muller early on, but Hannover levelled before half time through Christian Schulz.
The home team were reduced to 10 men just after the interval when goalkeeper Christian Wetklo was given his marching orders, but they still managed to find a winner in the 89th minute through Adam Szalai.
Mainz were confident after a 3-1 win at local rivals Frankfurt in midweek and set about making it two wins in a row with Shawn Parker dangerous early on.
He set up Muller to give the home team the lead in the 10th minute with his shot saved by Ron Robert Zieler and the ball came back off the post for Muller to poke home.
Hannover responded immediately and were level in the 28th minute when Schulz, while falling to the ground, was still able to divert Lars Stindl's deflected shot over the line.
It remained an open game until a red card for Wetklo, who handled the ball outside the penalty area, put the ball back in Hannover's court.
Mirko Slomka's side were unable to take advantage of having an extra man, though, and it was Mainz who ended the game the stronger.
And they were rewarded with a minute left when Szalai headed in Eugen Polanski's cross.