Jed-Forest were 8-0 down following a penalty and unconverted try, before Connor Hogg barged over for his third touchdown of the season, converted by Gregor Mein.
Accies kicked penalties before and after half-time – despite being a man down.
Fraser Harkness scored Jed’s second try, but Mein missed the conversion from out wide.
Robbie Shirra-Gibb had a couple of half-breaks up the wee stand side, but they didn’t come to anything and it looked like it was all over.
Accies were awarded a penalty wide out with a minute to go and hit the post – and Jed collected it. The ball went through many hands before Chris Gillonsold the last three tacklers a shuffle for a brilliant, match-winning team try.