The win helped Hamburg climb up to 11th, leading Werder on goal difference. Hamburg is one point and two places above Hannover, which is three points from the relegation zone.
"We all have to understand finally that we are in a dangerous situation," Hannover goalkeeper Ron-Robert Zieler said. "We don't have to play beautifully but we have to get some points."
Hannover got off to a promising start when Huszti punished mistakes by Hamburg's goalkeeper Rene Adler and Tomas Rincon. Adler kicked the ball to Rincon, who was surrounded by three Hannover players and could not control it. Huszti took advantage to steal the ball and slot past Adler.
Badelj replied quickly. Zieler punched a free kick from Calhanoglu outside the box, but Badelj fired a perfectly timed volley over the goalkeeper into the net.
Beister put the home side ahead for good less than a minute into the second half with a diving header from Heiko Westermann's long cross.
"We fought back well and deserved to win," Beister said.
Beister turned provider for Calhanoglu's goal in the 84th.
Mainz profited from two bizarre mistakes by Werder goalkeeper Sebastian Mielitz early in the match.
Mielitz came out far away from his goal in the seventh minute but did not go for Sebastian Polter's long ball which Nicolai Mueller looped over the 'keeper into the net.
Ten minutes later, Mielitz misjudged a high ball from Zdenek Pospech, let it bounce off the crossbar and Okazaki pounced to score from close range.
Okazaki's clinical finishing from a counterattack made it 3-0 in the 70th, before Eljero Elia and Franco Di Santo scored in the last five minutes to make the finish interesting.
Bremen fell to its second straight loss, while Mainz won its second straight.