Huub Stevens' side have not enjoyed the 2014-15 season to date, having made a start so poor that coach Armin Veh had to make way for the current coach's return.
But they moved out of the relegation zone with an impressive away win - only their fourth top-flight triumph of the campaign.
Austrian defender Florian Klein scored the game's only goal in the 42nd minute, converting Alexandru Maxim's assist.
Stuttgart's chances of victory were harmed with 37 minutes to play, though, when Georg Niedermeier was sent from the field.
But Hamburg were unable to make the most of their numerical advantage as Stevens' men held on for a crucial win that lifted them to 15th, behind their hosts on goal difference only.
Arjen Robben's 100th Bayern goal set them on their way in a routine 2-0 home win over Freiburg.
Robben headed home Franck Ribery's knock-down four minutes before half-time and the leaders - who are unbeaten in the league this season - sealed their win just after the break.
Thomas Muller headed home the rebound after Juan Bernat hit the crossbar on a night where Robert Lewandowski went off at half-time having taken a knock to his leg.
The win extended Bayern's lead at the summit to 12 points, but second-placed Wolfsburg can close the gap on Wednesday at Borussia Dortmund.
Hannover also recorded a 2-0 home win - goals from Salif Sane and Joselu seeing them defeat Augsburg 2-0 to jump to eighth.
Elsewhere on Tuesday, Cologne and Mainz played out a goalless draw.
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1