Chris Taylor's goal deep into injury time saw Oldham leapfrog fellow play-off hopefuls Millwall into fourth.
The Latics opened the scoring when Neal Eardley charged down the right and crossed for Deane Smalley to bundle in.
Oldham doubled their lead as Lee Hughes glanced home from a Kevin Maher free-kick but Neil Harris got one back from the spot after a foul on Dave Martin.
Ashley Grimes curled a leveller but Taylor headed in Maher's cross to win it in dramatic fashion.
Bookmark with:
What are these?