Matt Smith's early opener was cancelled out by Luis Suarez but a howler by Reds goalkeeper Brad Jones allowed Smith to restore Oldham's lead on the stroke of half-time.
Reece Wabara powerfully headed in a third for the League One club and, even though Joe Allen reduced Liverpool's arrears with a deflected volley, Oldham clung on to seal a famous win.
Smith gave indication of his threat in just the third minute with the sort of goal you associate with a player of his physical stature. Youssouf M'Changama swung over a cross from the left and the 23-year-old used every inch of his 6ft 6in frame to out-muscle Sebastian Coates and head past Jones.
The first half had an edge to it as Raheem Sterling was booked for challenge on M'Changama which ultimately forced the Oldham midfielder off after just 10 minutes.
Robbie Simpson, a scorer at Anfield in Oldham's 5-1 third-round defeat last season, was also cautioned for going in on Jones after the goalkeeper had failed to hold the ball - which turned out to be a pre-cursor of what was to come.
Suarez, captaining on the day, brought Liverpool level in the 17th minute when he set off on a driving run from deep and looked to pass but got a lucky rebound off defender Cliff Byrne and reacted quickly to hammer the ball inside Dean Bouzanis' left-hand post.
The Uruguayan's touch to Jordan Henderson's inswinging free-kick then diverted the ball into the net only to be denied by an offside flag, while Sterling should have scored after Suarez's pass was backheeled into his path by Fabio Borini but he shot straight at the keeper.
But Oldham remained unbowed as they took great heart from the physical battles they were winning and were rewarded with a second goal moments before the interval.
Smith, who had already had a header tipped over by Jones in added time, converted the simplest of chances after a howler by the Liverpool goalkeeper who fumbled Wabara's cross to allow Lee Croft to square a pass for the striker to poke home.
Borini had the chance to equalise from Jack Robinson's cross with the second half less than a minute old but he side-footed over and it proved costly.
The visitors' defensive fallibility in the air was exposed again on 48 minutes as Carl Winchester swung a cross to the far post and Wabara rose above Robinson to head over Jones into the far corner.
Steven Gerrard's introduction from the bench was not long in coming and the England captain soon had a shot blocked from which Daniel Sturridge blazed over.
Allen pulled one back with 11 minutes to go to with a shot which deflected in off Joe Baxter but Oldham held on to reach the fifth round for the first time in 19 years.