Chris Llewellyn settled the tie in favour of Wrexham but Oldham were already down to ten men and staring defeat in the face when it happened.
His tame shot should have been no trouble for goalkeeper Les Pogliacomi but somehow the save went wrong and the ball trickled into the back of the net.
With a two-goal lead from the first leg, Wrexham might have settled for a defensive game but instead went flat out for goals from the start.
Mark Jones nearly scored early on but Will Haining's challenge blocked his shot and the ball ran to Llewellyn, who was denied by the keeper's brave diving save.
Wrexham were denied an early penalty appeal when Guy Branston's pull on hot-shot Juan Ugarte brought him down in the box but referee Graham Laws overruled his assistant and waved play off.
Oldham made two openings as Neil Kilkenny set up a chance with a well-placed corner that zipped through a crowded goalmouth, while David Eyres fired an angled shot over the crossbar.
At the other end Jones was just too high with a 20-yarder, Ugarte saw a shot blocked and from the rebound Darren Ferguson hit tamely against the foot of the post.
Carlos Edwards was also out of luck with an accurate drive that the keeper held on to.
Branston was on target with a firm header from a Mark Bonner cross and seemed certain to give Oldham the lead only to be foiled by goalkeeper Ben Foster tipping it one-handed over the bar.
Branston was sent off on the hour for a foul on Carlos Edwards and there was no way back for the Latics.
Llewellyn's goal followed within five minutes and Wrexham spent the last period camped out in Lactics territory.