The 26-year-old, who joined Gladbach from Augsburg in summer 2014 and has one full international cap for Germany to his name, has agreed a four-year deal at HSV.
Hahn made 30 Bundesliga appearances for the Foals in 2016/17, but only 18 in the starting line-up, scoring three and providing one assist. All told, he made 95 appearances in all competitions for the Rhineland club.
"I had a great time at Borussia," Hahn said. "I'll look back on it fondly, but now the time has come for a new challenge. I know Hamburg well, and I'm really looking forward to what lies ahead."
Watch: Andre Hahn comes back to haunt former club Augsburg
The midfielder's arrival continues a busy off-season for HSV. They recently tied key striker Bobby Wood to a long-term contract extension, recruited Kyriakos Papadopoulos on a permanent deal, allowed former Germany No.1 Rene Adler to join Mainz, and signed Germany U-21 custodian Julian Pollersbeck from Kaiserslautern.