Hakan Calhanoglu was dismissed in the 53rd minute for his second bookable offence and Maxim's goal 16 minutes later handed Stuttgart their first win in 10 Bundesliga games and saw them leapfrog their opponents and move out of the drop zone.
Vedad Ibisevic returned to the Stuttgart starting line-up for Huub Stevens' first home match since taking over from Thomas Schneider a fortnight ago.
The Swabians looked eager to address their horrible run of form and Ibrahima Traore's dribble into the box was smothered quickly by Rene Adler in the opening minute.
Ibisevic's first good effort came in the 19th minute from Arthur Boka's free kick then, a minute later, he headed over the crossbar from Konstantin Rausch's cross.
However, Hamburg kept the score at 0-0 and began to take control in the last 15 minutes of the first half.
Defender Michael Mancienne squandered a half-chance from a corner kick on the half hour mark, before Croatian Milan Badelj came close with an effort of his own.
But Mirko Slomka's side were dealt a blow at the start of the second half when attacking-midfielder Calhanoglu was handed a second booking for a foul on Christian Gentner.
The former European Cup winners couldn't hold out much longer and the hosts took the lead with 21 minutes remaining.
Traore's pacey dribble left Heiko Westermann for dead on the right wing and the Stuttgart wide-man laid off to substitute Maxim who tapped home with ease.
Both Timo Werner and Rausch passed up opportunities to make the game safe, but Westermann squandered a golden chance from six yards to level in stoppage time.