Rotherham came from behind to beat 10-man Oldham 3-2 thanks to a double strike by Daniel Nardiello, but the visitors fought every inch of the way and the winner only came in the 89th minute.
The hosts almost went ahead in the first minute when a defensive header from Ben Pringle's free-kick went just wide of the upright.
At the other end, Scott Shearer made a smart save after 15 minutes to deny Korey Smith, but six minutes later Rotherham went ahead from the penalty spot.
Pringle's attempted cross was clearly handled by Matteo Lanzoni and Nardiello scored from the spot for the second game in succession.
After 33 minutes only a brilliant save by Mark Oxley denied Nardiello his second, with the keeper somehow turning his close-range effort round the upright.
The visitors were a man down after 40 minutes when David Mellor received a straight red card for kicking at Lee Frecklington, but two minutes later Oldham drew level, Cristian Montano breaking clear down the left and planting a shot wide of Shearer from just inside the box.
Eight minutes after the re-start the 10 men valiantly took the lead as Adam Rooney's header from a Joseph Mills free-kick was saved by Shearer, but he could only palm the ball straight to Lanzoni, who made up for his earlier mistake with a simple tap in.
Rotherham took 10 minutes to equalise, Frecklington's glancing header from Pringle's corner finding the corner of the net.
And the winner came in the last minute of normal time when Alex Revell's shot was beaten out by Oxley and Nardiello slammed the ball home from six yards out.