Liverpool went into this game looking to set a new club record of 26 games unbeaten, as well as get a win that would move them up to second and within a point of leaders Chelsea.
But they fell behind early on when Alisson, under pressure from Angelo Ogbonna, flapped at Pablo Fornals’ corner and succeeded only in helping the ball into his own goal.
Both sides were then fortunate not to be reduced to 10 men in a scrappy first half, with Aaron Cresswell catching Jordan Henderson with a heavy challenge before Ogbonna was hit in the face by a stray Diogo Jota elbow that resulted in the West Ham defender having to be substituted.
But a moment of quality four minutes before half-time brought Liverpool level when Trent Alexander-Arnold curled home a stunning strike after playing a short free-kick to Mohamed Salah.
Craig Dawson hit the woodwork with a header from a corner for West Ham after the break before Lukasz Fabianski superbly kept out Sadio Mane’s fierce volley from close range.
But West Ham regained the lead midway through the second half when Fornals was slipped through on goal and Alisson was unable to keep out his low shot.
That goal led to the London Stadium exploding into deafening noise, which became even louder when Kurt Zouma headed in a corner minutes later.
Divock Origi swept in a second on the turn to give Liverpool hope of rescuing something, but West Ham kept their nerve to take the three points.
The Hammers are third, level on 23 points with second place Manchester City and three points behind leaders Chelsea. Liverpool, meanwhile, drop to fourth on 22 points.
Defensive slip ups cost Reds
It has been a week of mixed emotions for Liverpool fans, with the high of an eye-catching 2-0 win against Atletico Madrid that secured progression to the Champions League knockout phase in midweek, sandwiched between two disappointing Premier League results.
The Reds let slip a 2-0 lead to draw 2-2 at home to Brighton last Saturday and the trip to West Ham offered the chance for Jurgen Klopp’s side to quickly get their title challenge back on track.
They went into the game on the back of a long unbeaten league run and free-scoring record away from home, having scored at least three goals in each of their five away games in the Premier League prior to the trip to West Ham.
This was a strange game in that they could easily have maintained that record as they scored two goals of real quality, while Mane really should have got a third in the dying seconds with a header that went just wide.
But defensively they were disappointing. While there were question marks over how much Alisson was impeded for the opener the Brazil goalkeeper should really have done better with West Ham’s second, but he allowed Fornals’ shot to creep past him.
That prompted a period in which West Ham broke their lines on a number of occasions as Liverpool struggled to cope with the hosts’ excellent counter-attacking.
It was a disappointing result for the Reds, but they will at least accept they were beaten by genuine rivals for the top four.
West Ham genuine contenders home and abroad
David Moyes has worked wonders since returning to West Ham two years ago, turning them from relegation candidates to a side that now has aspirations of playing Champions League football.
But this was arguably one of the most eye-catching results of the former Manchester United boss’ tenure.
Once again they displayed the characteristics they have been renowned for under the Scot – a disciplined defence coupled with a devastatingly quick and precise attack on the counter.
Liverpool have proven a bogey side for West Ham in recent years, winning eight and drawing two of their 10 encounters prior to Sunday’s game, but rarely did the Reds look like extending that unbeaten run in this game.
It is now four league wins in a row for Moyes’ side and with the Hammers also in the Carabao Cup quarter-finals and the knockout phases of the Europa League, fans can rightly dream of more magical moments to come this season.