A last-minute header from Wales international striker Craig Davies sealed the three points for Oldham.
Summer signing Davies is already repaying Oldham's faith
Swansea had a disastrous start as Alan Tate brought Davies down in the box after just 40 seconds, Michael Ricketts converting from the spot.
A superb Jason Scotland goal after the break levelled it, the striker standing a hard John Thompson tackle, turning, swivelling and finishing delightfully.
Then, in the dying seconds, Davies got on the end of a Deane Smalley corner.
At the end of a bad-tempered game, Oldham manager John Sheridan was sent to the stands.
He was escorted off by two police officers after protesting too much when loan signing Neil Kilkenny was brought down in a two-man tackle.
Oldham: Crossley, Eardley, Thompson, Gregan, Giddings, Allott, Kalala, Kilkenny, Taylor, Ricketts, Davies.
Subs: Liddell, Bell, McDonald, Smalley, Wolfenden.
Goals: Ricketts 3, Davies 90.
Swansea: de Vries, Tate, Bodde, Britton, Pratley, Scotland, Duffy, Painter, Lawrence, Robinson, Rangel.
Subs: Austin, O'Leary, Bauza, Anderson, Hawthorne.
Goals: Scotland 55.
Ref: A Hall.