Cheltenham Town will go into the last day of the season knowing a defeat against promotion-chasing Doncaster could condemn them to League Two.
The Robins have suffered four consecutive losses and are at risk of throwing away a great chance of avoiding the drop.
Steven Gillespie's 15th goal of the campaign was not enough to save them at Oldham, who sealed victory three minutes from time thanks to striker Lewis Alessandra.
Cheltenham's fate is in their own hands and manager Keith Downing believes they can save themselves next weekend. He said: "Emotions are raw when you have lost a game in the last five minutes, but I have to remain upbeat and the players are really keen to finish the job.
"We do not want to lose six months of hard work. The Doncaster game is going to be tough, but it is like a one-off cup-tie and we have been strong at home."
Cheltenham had their chances in an open first half and went close after only three minutes when Alex Russell was inches away from converting a 25-yard free-kick.
But Oldham made the breakthrough when Matt Wolfenden's shot was cleared off the line by Craig Armstrong and Deane Smalley snapped up the rebound to drive home from ten yards.
Gillespie shot wide for the visitors before Jamie Vincent was denied by a superb clearance from Oldham's Dutch defender Stefan Stam.
Cheltenham equalised shortly after half-time when Gillespie sent Mark Crossley the wrong way from the penalty spot after Sean Gregan's foul on Shane Duff.
Paul Connor and Russell both drew saves from Crossley as Cheltenham got on top, but they were finished off late in the game when Smalley set up Alessandra, who bundled home at the second attempt after his first shot from six yards was blocked by keeper Shane Higgs.