The first half was all action, with impressive youngster Zavon Hines spurning a glorious chance in the opening minutes after woeful defending by Jamie Carragher.
Torres opened the scoring for Liverpool with an wonderful solo goal before Alessandro Diamanti equalised for the Hammers from the penalty spot. Two goals from corners followed, as Carlton Cole cancelled out Dirk Kuyt's goal for the Reds.
Inevitably, the frenetic pace of the game dissipated in the second half, with West Ham trying to limit Liverpool's attacking play. The Hammers couldn't keep the Reds out as a Torres header saw Liverpool recapture their lead for the third time on the night.
Hines almost scored for West Ham in the third minute of the game. Carragher made a horrible mistake after Glen Johnson stole the ball away from Cole on the right. The Liverpudlian allowed Hines to pinch the ball off him on the edge of his own box.
The Jamaican only had Pepe Reina to beat and was inches away from opening the scoring as his shot rebounding off the far post. Liverpool managed to scramble the ball clear and were lucky to escape with the scores level.
Emiliano Insua intercepted a Hines pass in the 19th minute and fed the ball out to Torres, who was just outside the box on the left-hand side. The Spaniard dazzled James Tomkins with his footwork and rounded his marker as he advanced into the penalty area.
In two touches, Torres was bearing down on goal and stretched as he slotted the ball past Robert Green at the near post. Great finish and 1-0 Liverpool.
Matthew Upson was injured as he lunged in vain to try and block Torres strike and was replaced by Daniel Gabbidon.
It went from bad to worse for the Hammers as Valon Behrami limped off minutes later and was replaced by Radoslav Kovac.
Hines picked the ball up on the left and drove past Carragher to advance into the penalty area. Carragher couldn't handle the lively youngster's pace and shoved the Jamaican to the ground. The referee rightly pointed to the spot.
Alessandro Diamanti stepped up and enjoyed a slice of good fortune to level the score. As the Italian stepped up to strike the ball his standing foot gave way and the ball looped straight down the middle into the top of the net. It wasn't intended but it was 1-1 with 29 minutes played.
Diamanti encourages the crowd after levelling from the spot
Liverpool retook the lead in the 41st minute through a well-worked set piece. Ex-Hammer Yossi Benayoun swung in a corner from the right-hand side as Steven Gerrard got a running jump on his marker. The Liverpool skipper's header was powerful and arched towards the bottom right corner.
It was Dirk Kuyt who got the last touch, as the Dutchman dived to make contact with an outstretched foot and directed the ball past Green.
Not to be undone, West Ham equalised from a corner from the same side that Liverpool scored from just before half-time. Mark Noble crossed in from the left and Carlton Cole sent a glancing header towards the bottom right corner. It was a fantastic header and left Pepe Reina with no chance, 2-2.
The second half started with West Ham withstanding a period of sustained Liverpool pressure. The away sides approach play was good but the Hammers were resolute in their defending. Liverpool worked an opportunity for Torres to attack on the left but Scott Parker won the ball with a crunching tackle.
West Ham ventured forward in the 59th minute and Julian Faubert won a corner on the right, as it was swung into the box Reina flapped unconvincingly at the ball to concede another corner. Luckily for Liverpool the Hammers wasted the opportunity with a poor corner from Noble.
Benayoun then sprung to life, displaying wonderful footwork on two occasions in as many minutes to penetrate the West Ham defence.
The Israeli then picked the ball up in the middle and weaved his way past multiple players, Benayoun was crowded out as he entered the box but managed to squeeze to ball out to substitute Ryan Babel on the right. The Dutchman's cross was poor and the chance was wasted.
Diamanti was withdrawn and replaced by Kieran Dyer and the former-Newcastle man showed a wonderful turn of pace to relieve the pressure on West Ham's back four.
Johnson drove at the West Ham defence in the 74th minute, he unleashed a shot on goal that was easily blocked, but the ball rebounded to Babel on the right who headed by the byline and floated a cross towards the far post.
Torres celebrates the first of his two decisive strikes
West Ham didn't give the game up and nearly equalised within a minute. Kovac met a cross from the left with a looping header towards the far post, and Reina produced a smart save to deny the Czech's effort.
As the end of the exhilarating contest approached Liverpool tightened their control of possession. A valiant yet increasingly tired West Ham struggled to create chances and it was Liverpool that looked the more likely to score the next goal.
The outstanding Torres was withdrawn in stoppage time as Liverpool held on for the victory.