Ryan Flynn gave Latics the lead with a superb individual effort before Will Grigg equalised 10 minutes before the end of the first half.
Wigan were reduced to 10 men on the stroke of half time as Jake Buxton’s reckless challenge on Marc Klok forced the referee to send the defender off.
Steve Robinson’s men looked the likelier of the two sides to get the winner in the second half and up popped Josh Law to grab the winning goal with only seven minutes left to play.
Robinson handed a full debut to academy graduate Kallum Mantack who lined up on the right hand side of a 4-5-1 formation.
It would be Wigan Athletic who shaded the early possession with Michael Jacobs going close with a free kick early on.
Latics grew into the game, however, and won a free kick on 13 minutes. Dutchman Klok stood over the ball, crossed to the far post for Peter Clarke but the ball was diverted behind for a corner.
Another Klok set piece followed as Latics were starting to push for an opening goal, but Cameron Burgess could not connect with his header correctly as the chance passed.
Latics did manage to take a deserved lead on 17 minutes through a superb individual goal from Flynn.
The midfielder picked the ball up halfway inside Wigan Athletic’s half, he danced his way through the defence and from 18 yards, slotted the ball into the far corner to give Latics the advantage.
Despite going a goal down, Wigan responded well and had chances to equalise straight away.
Ryan Colclough tested the palms of goalkeeper Connor Ripley, whilst last ditch defending from centre back Clarke denied Jordan Flores a sight of goal.
Just after the half hour mark, the visitors did find the equaliser as Grigg found the back of the net from close range.
Flores’ corner into the box was not cleared properly and Grigg converted on the volley from six yards to equalise for the Championship side.
That goal seemed to rattle Latics and minutes later, Wigan Athletic almost took the lead. The ball fell perfectly for Max Power, who was 25 yards from goal, but goalkeeper Ripley was equal to his curled effort.
The game did start to heat up in the final five minutes of the first half as Klok was booked for a late challenge, however, Wigan were reduced to 10 men on the stroke of half time.
Buxton’s reckless challenge on midfielder Klok earned him a straight red card and Wigan found themselves a man down going into the interval.
Latics tried to make their extra man count after the break and Klok’s free kick two minutes into the second half flew inches over the crossbar.
The visitors, despite their man disadvantage, almost took the lead minutes later as Colclough raced through on goal but, under pressure, he struck wide of Ripley’s goal.
Lee Croft, who was introduced at half time, was straight into the action, crossing for goalscorer Flynn but, on this occasion, the midfielder screwed his effort from 18 yards over the crossbar.
Latics striker Lee Erwin went close on two occasions just before the hour mark as he created space for himself inside the D but his deflected shot was into the palms of Jussi Jaaskelainen.
The Leeds United loanee had another great opportunity to put Latics ahead a minute later but headed straight at the goalkeeper from eight yards after great work from Flynn.
Latics continued their spell of pressure as former Sheffield United man Flynn raced down the left hand side, cut the ball back for Green but the midfielder could not find a way past the stubborn Wigan Athletic goalkeeper.
Midfielder Ollie Banks was brought into the action and made an immediate impact. The midfielder’s whipped corner found the head of the onrushing Clarke but he powered his header past the post as Latics pushed for a winning goal against the 10-men.
However, there were some nervy moments for Athletic as Michael Jacobs was presented with a set piece opportunity from 25 yards. Ripley lined up a five man wall but Jacobs’ free kick, from 25 yards, deflected over for a corner.
Latics managed to clear the danger from the resulting corner and on 83 minutes won the game through an unlikely source.
Law, who was Robinson’s first signing as manager, played a one-two with Flynn on the edge of the box.
The 26-year-old continued his run into the penalty box, where he was picked out and he cooly slotted the ball past Jaaskelainen to give Latics the lead in the final minutes of the game.
Athletic’s hard work was almost undone a minute later as Wigan had a chance to equalise straight away. Power managed to create half a yard of space but Latics threw bodies in the way of the ball, stood firm and cleared the danger.
Whistles ringed around the stadium from nervous supporters and they were quickly met by huge cheers as the referee signalled the end of the game, and Latics were into the hat for the second round of the competition.
Oldham Athletic: Ripley, Law, Burgess, Clarke, Wilson, Klok (Banks 61’), Fane, Green, Mantack (Croft 46’), Flynn, Erwin (Cassidy 87’).
Subs not used: Kettings, Edmundson, Osei, McLaughlin.
Wigan Athletic: Jaaskelaininen, Buxton, Perkins, Daniels, Power, Grigg (Barrigan 70’), Flores, Jacobs, Chow (O’Brien 87’), Warnock, Colclough (Cosgrove 87’).
Subs not used: Bogdan, Hendry, Burke, Gregory.
Goals: Oldham Athletic (Flynn 18’, Law 83’) 2-1 Wigan Athletic (Grigg 34’)