Ryan Flynn's 87th-minute strike saw Oldham snatch a 2-1 win at Gillingham.
Cody McDonald had given Gills a half-time lead, but goals after the break from Freddie Ladapo and Flynn earned Oldham their first league win since August.
McDonald was the beneficiary of a superb inswinging corner by Bradley Dack and nodded in unmarked at the back post after 10 minutes.
McDonald should have had his second in the 26th minute but his glancing header went straight into the arms of Connor Ripley.
Ladapo, on as a substitute on the hour-mark, scored with his first touch five minutes later, slamming a shot from 12 yards past Stuart Nelson.
But Oldham were not content to settle for just a point and former Liverpool player Flynn earned a much-needed win for manager Steve Robinson.
The midfielder pounced on a loose ball following a deflected Paul Green shot and slotted into an empty net.
The goal capped a remarkable comeback from the team who started the day bottom of the league.
tagged in Liverpool