Hammill slammed in the winner on 82 minutes after the ball fell kindly for him when James Vaughan jostled for Jon Stead’s through pass.
It had looked like the Addicks, who led 1-0 and 2-1, were going to progress thanks to striker Marvin Sordell’s first goal for the club.
Sordell, on loan from Bolton, swept the ball in from close range on 59 minutes after Joe Pigott nodded down Cedric Evina’s cross. Prior to that Dale Stephens and Joel Lynch had traded efforts.
Sordell was arguably lucky to be still on the field having only been booked for a bad lunge on Town skipper Peter Clarke minutes earlier.
Substitute Sean Scannell and Hammill responded by putting Adam Clayton through on 57 minutes, with the midfielder rounding keeper Ben Hamer only to fluff an open goal.
Town drew level, though, on 77 minutes when Jonathan Hogg netted his first for the Terriers with a deflected 25-yard shot.
And Hammill, who scored against Bournemouth on Saturday, then won it, before nearly adding gloss to the scoreline in stoppage time when he was denied by Hamer.
Huddersfield were hardly in it for the first half hour and it took a soft opening goal from Stephens to wake them up.
Huddersfield’s Oliver Norwood fouled Evina on the left edge of the box on 32 minutes and Stephens struck the resulting free-kick.
It was hit low, went through the wall and then a crowd of players around the six-yard area before creeping in at the far post.
Town fielded the same side as Saturday but the performance lacked the intensity that blew away Bournemouth 5-1 until they fell a goal behind.
A flowing move involving Norwood and Hogg saw Vaughan denied by Hamer from Hammill’s cross.
Norwood then made amends for his role in Charlton’s goal by setting up Lynch for the equaliser on 40 minutes.
The ex-Brighton man lashed in an angled shot from 25 yards which Hamer might have done better with at his near post.
Charlton, who made eight changes to the line-up which featured in Saturday’s abandoned game against Doncaster, made all the early running.
Pigott beat Anthony Gerrard for pace down the middle after just three minutes and slipped a pass for Lawrie Wilson, whose shot was blocked by Lynch.
Michael Morrison was also twice denied while there were further chances for Wilson and Bradley Pritchard in an impressive opening spell.
But Huddersfield finished strongly, with substitute Stead a constant threat, and they could have won by more in the end.