During a dramatic clash on the Pennines, the Foxes took the lead before half-time through Josh Knight, but their advantage was overturned by a brace from Craig Davies after the interval.
While Ahmed Musa restored parity in the 68th minute, Anthony Gerrard and Tope Obadeyi struck late on to secure Oldham’s place in the Quarter-Finals.
City made three changes from the 0-0 draw at West Ham United on Friday night with Ben Hamer, Kiernan Dewsbury-Hall and new signing Fousseni Diabaté coming into the fold.
While Oldham’s starting line-up was an experienced one, former Fox and current Latics manager Richie Wellens handed second-year academy scholar Tom Hamer a full debut.
The first chance fell to the feet of Brian Wilson for the hosts, but Hamer got a strong hand to his powerful drive from the edge of the 18-yard box.
The Sky Bet League 1 side were handed a free-kick on the periphery of Hamer’s box after 18 minutes. The Foxes stopper, though, collected Kendai Benyu’s curler relatively comfortably.
Oldham continued to threaten and, if not for the brave efforts of Robert Huth, they may have taken the lead in the 21st minute as the German’s head denied Tope Obadeyi from 16 yards out.
With five minutes of the half to go, George Edmundson looped a header over the defence, but the Latics man’s attempt came back off the post.
City broke with two minutes to go and, when Dewsbury-Hall’s long-range effort was spilled by Johny Placide straight into Knight’s path, the centre-back struck for his sixth goal of the season.
The Latics were back in the tie on 50 minutes, however, when Davies completed a swift counter with a tidy finish past Hamer from 12 yards out.
Another five minutes passed until Connor Wood was adjudged by the referee to have handled Ousmane Fane’s cross in the area, leading to a contentious penalty call.
While Hamer was able to get a hand on Davies’s spot-kick, there was little that could be done to keep out the rebound. Leicester’s lead had been overturned.
A glimmer of hope came when Dewsbury-Hall’s excellent pass was sent to Musa by Barnes, to make it 2-2 on 68 minutes, but Oldham struck twice more late on.
Gerrard's smart finish, slotted past Hamer from 10 yards, swung the pendulum pack in Oldham’s favour with just 14 remaining minutes on the clock before Obadeyi later added a fourth.
As a result, City's 19-game unbeaten run, which stretched back to mid-September, comes to a close.
Major moment…
The decision which led to Oldham’s penalty in the 55th minute ultimately ended up costing City as Oldham’s recovery gathered steam, despite Ahmed Musa’s strike with 22 minutes to go.
It handed the hosts momentum to build upon and they seized it during a frantic second half spell to seal their place in the Quarter-Finals.
Who impressed?
Now a regular feature of Steve Beaglehole’s Development Squad, Kiernan Dewsbury-Hall impressed many at Boundary Park with his expressive football in the middle of the park.
The midfielder also played a large role in City’s second of the night, playing a wonderful through ball into Harvey Barnes, to exhibit his abilities going forward.
Where does it leave us?
After emerging from a group which included Fleetwood Town, Carlisle United and Morecambe – as well as beating Scunthorpe United last time out – City exit the competition in the last-16.
Coming up…
A trip to Sunderland on Tuesday night awaits the Foxes in the Premier League International Cup at the Eppleton Colliery Welfare Ground (7pm kick-off).
The details…
Oldham: Placide, Wilson, Gerrard (c), Benyu (Amadi-Holloway 45), Davies, Edmundson, Pringle, Fane (Omrani 82), Nepomuceno, Obadeyi, Hamer (Maouche 69)
Subs not used: Kyeremeh, Duffus, Scholes-Beard, Uche
Goals: Davies 50, 55, Gerrard 76, Obadeyi 86
City: Hamer, Huth, Musa, G. Thomas, Barnes, Diabaté (Gordon 69), Knight, Choudhury (c), Hughes, Wood, Dewsbury-Hall (Eppiah 81)
Subs not used: Johnson, L. Thomas, Ndukwu, Iversen, Leshabela
Goals: Knight 43, Musa 68
Attendance: 1,192
Referee: Ben Toner