Robert Lewandowski put the hosts ahead in the 17th minute but within quarter-of-an-hour Dortmund found themselves trailing 2-1 and down to 10 men with Lewandowski the man dismissed.
The numbers were evened up in the 59th minute when Jeffrey Bruma was handed his marching orders but Dortmund could not take advantage as further goals from Son Heung-min and Artjoms Rudnevs - both scoring for the second time in the match - earned Hamburg the victory.
The defeat sees reigning champions Dortmund remain on 39 points, 12 behind Bayern who were playing later on Saturday.
Hamburg, meanwhile, climb up to 31 points after collecting their second victory of 2013.
Dortmund went ahead when Hamburg defender Heiko Westermann casually let Lewandowski get behind him following a long ball forward, and the Poland international chested the ball forward and then struck his 14th goal of the season between the legs of visiting keeper Rene Adler.
Hamburg responded a minute later, though, with Marcell Jansen sending a pass down the left side to Dennis Aogo, who crossed into the box where Rudnevs fired home the equaliser from five yards out.
Hamburg took the lead in the 26th minute with an impressive goal from Son as the South Korean got past Mats Hummels in midfield, turned in from the right side and unleashed a left-footed strike that went in off the far post.
Dortmund went a man down after 31 minutes when Lewandowski was red-carded for his challenge on Per Ciljan Skjelbred.
The hosts appeared to equalise two minutes into first-half stoppage-time but Mario Gotze's goal was disallowed as Marco Reus was ruled offside.
Hamburg saw defender Bruma dismissed in the 59th minute as he was shown red for his professional foul on Reus.
However, Hamburg came up with the perfect answer as they increased their lead in the 62nd minute when Rafael van der Vaart sent a cross from the left beyond the right post where Rudnevs headed between the legs of Dortmund keeper Roman Weidenfeller.
Hamburg wrapped up the win with their fourth in the 89th minute when Son slotted home Jansen's cross from the left side.