Midfielder Paul Murray struck his ninth goal of the season as Oldham virtually secured their Division Two place for next season.
Murray struck in the eighth minute and Jamaican international Jermaine Johnson doubled the lead midway through the second half as Oldham ended Swindon's hopes of automatic promotion.
It was the lively Johnson who teed up Murray to fire home an unstoppable 25-yard shot as the visitors took an unexpected lead.
Swindon striker Rory Fallon was guilty of missing a good chance on 19 minutes when his volley from an Andrew Nicholas cross sailed over the bar.
Oldham keeper Les Pogliacomi was called into action after 31 minutes when Brian Howard's free-kick fell kindly to Stefani Miglioranzi. The giant Australian pulled off a superb one handed save to deny the former Portsmouth midfielder.
The Latics almost doubled their lead just after the interval when David Eyres' free-kick found Dean Holden free in the box, only for his volley to fall just wide of the left hand post .
But the visitors eventually carved out the second on 74 minutes following good work by Darren Sheridan. His pinpoint throughball found Johnson and he outpaced the Swindon defence to fire his shot home.
But Town were back in it moments later when Fallon got on the end of Andy Gurney's cross to reduce the deficit back to one.
Swindon rallied late on but the Latics' defence held firm as they held on for a vital three points in their bid to preserve their Division Two status.
Swindon manager Andy King said: "All of my players were useless today apart from Sean O'Hanlon.
"That was our worst performance for ages and when nine of your outfield players don't perform you get beat." Oldham manager Brian Talbot's side now need just one more point to stay up.
Talbot said: "In the ten games I have been here we have only been beaten once and that's enabled us to be in the position we are.
"We were confident of getting a result today and we knew they would throw everything at us in the second half, but our defence withstood the pressure well."