Torres took his tally in the Premier League to 18 goals
Fernando Torres scored a hat-trick as Liverpool won their game in hand to move above Everton and into fourth place in the Premier League.
Torres superbly finished Dirk Kuyt's low cross from 12 yards and struck after the break with a header following another cross from the Dutchman.
The Spain striker hit the post with a diving header before netting his third with a low finish from a tight angle.
Steven Gerrard scored the fourth with a spectacular long-range effort.
It was a crucial win for the home team in the context of the scramble for fourth spot - and with it a place in next season's Champions League.
Until they scored the decisive second goal it was a far from scintillating performance by Liverpool, who at times lacked urgency and were wasteful from set pieces.
But West Ham, defeated 4-0 by Chelsea on Saturday, rarely looked as though they would force their way back into the contest after Torres struck early on.
By the time Alan Curbishley introduced Dean Ashton and Bobby Zamora after 69 minutes the game had gone - and it was the home team who added to their tally with two late goals.
Liverpool started with a real sense of purpose and should have scored even before Torres' eighth-minute opener.
John Arne Riise, recalled to the team, crossed from the left and Kuyt headed the ball back across goal to Torres, who missed the target from six yards.
The Spaniard soon made amends with his 16th goal in the Premier League.
Torres got across Anton Ferdinand and showed superb technique to drill home Kuyt's low cross from the right.
The goal marked the end of Liverpool's early dominance, with West Ham gradually feeling their way into the contest.
Pepe Reina charged from his goal after the ball was slipped through to Luis Boa Morte and the West Ham striker eased past the Liverpool keeper before shooting from a tight angle.
The ball seemed to be heading goalwards before a superb sliding effort from Alvaro Arbeloa diverted it out for a corner.
The game went through a dour, chanceless phase, before Liverpool pushed for a second goal in the period before half-time.
Martin Skrtel narrowly missed with a header at the near post while Gerrard toe-poked a cross from Ryan Babel towards the bottom corner of the West Ham goal that produced an excellent low save from Robert Green.
Liverpool forced the first good effort of the second half, with a superb disguised pass from Gerrard creating an opening for Babel, who forced a decent save from Green.
But it was mediocre fare, with errant passes and niggling fouls upsetting the flow of the game.
Torres brought the contest back to life with his precise header into the top corner, but in truth the West Ham marking was dreadful and the striker was under no pressure as he extended his team's lead.
And having established a two-goal cushion, Liverpool took complete control.
Torres met a superb cross from Gerrard with a diving header that rebounded off the woodwork.
But he completed his third hat-trick for Liverpool after easily skipping past Lucas Neill and passing the ball into the net.
Gerrard finished the scoring with his spectacular strike after the Hammers defence backed off and allowed him to run at goal.
Liverpool boss Rafael Benitez:
"At the end I was really pleased with the performance of the team.
"Torres is on fire and that is good for him and fantastic for the team.
"We now have a really important game game against Newcastle and we have to make sure we get three points."
West Ham boss Alan Curbishley (whose team lost 4-1 to Chelsea on Saturday):
"We made no impression on Liverpool at all.
"It's the second time in four days we've played a top side and we knew it would be a tough game but we did not expect this. We have let ourselves down."
Liverpool: Reina, Arbeloa, Skrtel, Carragher, Riise, Gerrard, Mascherano, Alonso, Babel (Pennant 76), Kuyt (Benayoun 63), Torres (Crouch 82).
Subs Not Used: Itandje, Hyypia.
Goals: Torres 8, 61, 81, Gerrard 83.
West Ham: Green, Neill, Ferdinand, Upson (Spector 63), McCartney, Solano (Ashton 69), Noble, Mullins, Ljungberg, Boa Morte, Cole (Zamora 69).
Subs Not Used: Wright, Pantsil.
Booked: Cole, Neill, Noble.
Ref: Steve Bennett (Kent).
BBC Sport Player Rater man of the match: Liverpool's Fernando Torres on 9.14 (on 90 minutes).
Please note that you can still give the players marks out of 10 on BBC Sport's Player Rater after the match has finished.