Teenager Matty Daly struck in the second minute of second-half injury time to give Huddersfield Town a first win in six games at out-of-form Charlton Athletic.
Charlton failed to register an effort on target in the match, but it looked like they would hold on to a point after goalkeeper Dillon Phillips had made a string saves and the Terriers had spurned several other chances.
Addicks striker Lyle Taylor had a late header ruled out for offside, but substitute Daly won it after turning home from 10 yards out after latching on to Florent Hadergjonaj's cut-back from the left.
Victory moved Danny Cowley's side up to 19th and put Town four points clear of the relegation zone, while injury-hit Charlton are now nine Championship matches without a win.
Kick-off was delayed by 10 minutes after the Huddersfield team coach was delayed in traffic, and Phillips saved a half-volleyed attempt from Josh Koroma and palmed a Steve Mounie shot from a narrow angle behind as persistent driving rain made conditions difficult in the first half.
The Terriers continued to have the upper hand in the second period, as Karlan Grant was twice denied by Phillips and Koroma had a low effort tipped wide.
Mounie and Elias Kachunga both sent headed efforts off target as the match headed for a stalemate before Taylor, making a second substitute appearance following 14 weeks out with a knee injury, thought he had won it for the hosts with four minutes remaining.
However, the assistant's flag was up against defender Naby Sarr in the build-up and the Terriers snatched a dramatic victory as 18-year-old midfielder Daly climbed off the bench to notch his first senior goal on his fifth outing for the Yorkshire club.
Charlton manager Lee Bowyer told BBC Radio London:
"I don't want to say the officials have cost us, but they have. They flagged for Naby [Sarr] being offside and he wasn't.
"It is harsh. The lads gave everything and they crawled off the pitch.
"I wish I could help them more and freshen things up better but we are limited at the moment and that is the reality of it.
"We are trying to grind out results and when you get the officials costing you it makes it even harder to take - and then they go and nick a goal in injury time. I am very disappointed."
Huddersfield Town boss Danny Cowley told BBC Radio Leeds:
"It's been a difficult period for us. Everything that could go wrong has gone wrong for us.
"What (this win) does show is that if we fight hard and show that level of determination, we can always find a way. We can leave this evening very proud.
"For us to find three points tonight, that was an amazing effort; to come away from home and find a way to win is incredible."