A second-half effort from ex-Hammer Joe Cole and an unfortunate James Collins own goal turned the game around late on for Brendan Rodgers' side.
Another former West Ham man, Glen Johnson, had given the visitors the lead with a superb strike but a Mark Noble penalty and a Steven Gerrard own goal put the home side in front at the break.
Liverpool began the brighter and looked set to make light of the loss of the suspended Luis Suarez with Jonjo Shelvey playing out of position as a makeshift centre-forward.
Johnson, in particular, was causing Matt Jarvis real problems defensively and the England right-back got his reward with the opening goal as he fired a right-footed shot into the top corner.
But West Ham had beaten Chelsea last week after conceding the first goal and they seemed undeterred by the setback as they pushed for an equaliser.
That came when Joe Allen blocked a fierce but wayward Mohamed Diame shot with his hand and referee Lee Probert pointed to the spot.
Noble converted the penalty in fine style with a measured finish to the right of Pepe Reina and the momentum of the game had shifted.
So had the balance of power down the flanks as Jarvis began to trouble Johnson in the opposite direction and it was a cross from the £10million summer signing that provided West Ham's second.
The Hammers took a quick free-kick to Jarvis in a wide left position and he was allowed space to curl in a right-footed cross that Gerrard could only divert with his head past his own goalkeeper.
With Carlton Cole leading the line well, West Ham looked comfortable but it was his namesake Joe who came off the bench to stun his old club with a neat left-footed finish on the turn.
Fellow substitute Jordan Henderson then whipped in a low cross that Shelvey and Collins challenged for at the near post and the ball looped off the defender's foot over the head of Jussi Jaaskelainen to complete a topsy-turvy game and snatch all three points for the Reds.