Robbie Simpson’s brilliant 30-yard goal had given the visitors a 28th-minute lead but a freak deflected equaliser from Craig Bellamy was followed by Gerrard’s penalty just before half-time.
Shelvey fired home from close range in the 68th minute before substitutes Andy Carroll and Stewart Downing wrapped up victory late on.
Gerrard was handed his first start since late October as manager Kenny Dalglish named a strong team for their FA Cup third round tie at home to Oldham.
With his family watching from the stand there was a minute’s applause for former Liverpool defender Gary Ablett, who died on New Year’s Day aged 46 after losing a 16-month battle with non-Hodgkin’s lymphoma.
In the fifth minute Dirk Kuyt, with just one goal in the Carling Cup this season, headed wide Craig Bellamy’s right-wing cross and they should have paid for that miss five minutes later.
Kuqi out-muscled Sebastian Coates and wrong-footed Jamie Carragher to put himself clear on the right of the area but with only goalkeeper Jose Reina to beat he wastefully drilled a shot into the side-netting.
Right-back Tom Adeyemi had an equally good chance from Robbie Simpson’s 14th-minute corner but planted his free header just over.
Oldham were creating the better chances and when Chris Taylor cut in from the left and exchanged passes with Simpson it was Carragher’s lunge which did enough to put him off and he fired wide.
Midway through the half Kuyt directed another header off target from Bellamy’s inswinging free-kick but unlike after his earlier effort Oldham did not let him off as lightly.
When James Wesolowski played the ball into Simpson 30 yards out he took one touch before unleashing a left-footed half-volley which flew past Reina. The goal had the Oldham contingent in the directors’ box on their feet but the lead lasted less than two minutes as the hosts equalised with a huge stroke of luck.
Jonjo Shelvey cut in from the right and aimed a speculative left-footed shot towards the far post but the ball took a huge deflection off Bellamy’s chest leaving Alex Cisak helpless.
The goalkeeper proved his worth moments later, however, when he batted away Maxi Rodriguez’s 14-yard shot from Bellamy’s cross.
Shelvey had a great chance to turn in the rebound but in his eagerness tripped over his own feet.
Cisak was lucky to escape conceding a second when his clearance bounced off Rodriguez to Bellamy inside the penalty area but the goalkeeper got back to collect.
But he could do nothing about the next chance as, a minute before half-time, Adeyemi fouled Rodriguez and Gerrard stepped up to dispatch the penalty.
Late in the second half Adeyemi appeared to take offence to something shouted from the Kop and despite reassurance from his team-mates, Kuyt and Gerrard the 20-year-old right-back, on loan from Bradford, seemed visibly upset.
There then appeared to be discussion between the fourth official and a police officer down by the tunnel.
Late on substitute Andy Carroll smashed in a low shot from outside the area barely two minutes after coming on and then Stewart Downing netted a fifth.
The final scoreline rather flattered Liverpool with Oldham having given an excellent account of themselves for much of an opening half when a little more composure could have seen them more than a goal ahead, but that will matter little to home manager Kenny Dalglish as he seeks his first trophy since returning to the helm.
The Adeyemi incidenct, however, will be one he is hoping proves of less consequence than it initially appeared with the club already dealing with the flak surrounding Luis Suarez, who watched from the stands.
Liverpool: Reina, Kelly, Carragher, Coates, Aurelio, Gerrard, Spearing, Maxi, Shelvey, Bellamy, Kuyt. Subs: Doni, Carrol, Henderson, Downing, Adam, Skrtel, Flanagan.
Oldham: Cisak, Lee, Mvoto, Diamond, Taylor, Adeymi, Wesolowski, Furman, Scapuzzi, Simpson, Kuqi. Subs: Bouzanis, Black, Morais, Smith, Tarkowski, Parker, Mancini.