Darwin Nunez scored a fine goal as Liverpool saw off West Ham to extend their unbeaten run to 18 games.
After Nayef Aguerd brought him down, Mohamed Salah gave the Reds the lead against the odds with a penalty.
Jarrod Bowen levelled for West Ham with an excellent stooping header to meet Vladimir Coufal’s cross.
Soon after, Curtis Jones had a goal ruled out for the Reds for offside.
Nunez put them ahead with a difficult hooked volley from Alexis MacAllister’s clipped ball over the top.
The Hammers played well in stages but never created a clear-cut chance to equalize.
And Diogo Jota sealed the points when he pounced from close range to turn home Virgil van Dijk’s header.
West Ham boss David Moyes has now lost 24 Premier League games against Liverpool, a joint record for a manager against one team, level with Harry Redknapp against Manchester United.