Birmingham earned their first win in six matches as defender Kyle Bartley scored twice before being sent off for his celebrations at Huddersfield.
Serbia striker Nikola Zigic gave the Blues the lead from close range before Anthony Gerrard levelled for Huddersfield.
Bartley, on loan from Swansea, headed Birmingham back into the lead after the interval after Jesse Lingard's corner.
He made it 3-1 after a free kick before being red carded for over-celebrating.
Bartley had already been booked for a foul and his dismissal left the visitors down to 10 men for the final nine minutes.
But Birmingham dug deep to claim victory, boss Lee Clark's first win over Huddersfield since he was sacked by the club in February 2012.
The visitors took the lead early on but were pegged back when Gerrard scored on his return to the Town side after a training ground bust-up.
Gerrard, cousin of Liverpool midfielder Steven, missed the previous two games following his involvement in an incident with Adam Clayton and Martin Paterson.
He made up by flicking home a header from Adam Hammill's free kick after 31 minutes to level the scores at 1-1.
Hammill started despite being fined and told by manager Mark Robins to "grow up" for his reaction to being substituted in
last week's defeat at Wigan.
Both teams came into this match with only two wins in their last 10 matches - with the hosts having lost three of their last four outings.
Birmingham made the brighter start thanks to ex-Huddersfield striker Lee Novak, who played in a wide role for the visitors.
He forced home keeper Alex Smithies into a good save early on. Lingard won a 50-50 in the centre circle and Nikola Zigic put Novak through.
Novak then helped put Birmingham in front with a shot from a tight angle on 11 minutes which keeper Alex Smithies did well to parry.
Zigic, who stands at 6ft 7ins, showed good athleticism to slide in at the far post and hook the rebound over the line from close range.
Novak, who joined on a free transfer in the summer, was a thorn in the side of his old club.
Smithies saved well when he fired in from 20 yards on 37 minutes and then saw a Novak header from a Mitch Hancox cross drift wide five minutes later.
The Terriers came more into it as the game went on. Sean Scannell twice went close while Ward headed over a Hammill free-kick after 23 minutes.
The sides traded blows early in the second half, with Novak again forcing Smithies to parry at one end and Hammill drilling just wide at the other.
Bartley's purple patch and red card followed, with Birmingham happy to see out the game after that.
Huddersfield boss Mark Robins:
"It was more than poor, it was abject. Our performance has dropped way below what we expect and we should be picking up points against sides in the bottom three.
"For whatever reason the players decided not to perform.
"We gifted them two goals. We have run out of ideas and all the work we have done on the training ground has been left on the training ground.
"It was just a bad day at the office."
Birmingham manager Lee Clark:
"Football is an emotional game.
"Kyle hasn't enticed the Huddersfield fans. He has gone to celebrate with his own fans and common-sense should prevail.
"Probably under the rules the referee had no option but you have to be allowed to celebrate. That's what the fans want to see."
- 01 Smithies
- 21 Richards Booked
- 03 Dixon
- 16 Southern
- 05 Clarke (Lynch - 7' Booked )
- 39 Gerrard
- 12 Hammill
- 04 Norwood (Gobern - 64' )
- 14 Stead (Carr - 64' )
- 07 Scannell
- 11 Ward
- 02 Woods
- 10 Gobern
- 13 Bennett
- 19 C. López
- 26 Carr
- 33 Lynch
- 38 Holmes
- 01 Randolph
- 31 Caddis
- 18 Hancox Booked
- 17 Reilly
- 05 Bartley Dismissed after an earlier booking
- 04 Robinson
- 07 Burke (Shinnie - 53' )
- 24 Adeyemi
- 19 Zigic (Løvenkrands - 90' )
- 12 Novak
- 09 Lingard (Burn - 83' )
- 06 Burn
- 11 Løvenkrands
- 13 Doyle
- 20 Lee
- 22 Shinnie
- 27 Ferguson
- 33 Gray
Ref: Gavin Ward