Jurgen Klopp’s team were one game away from setting a new club record of 26 matches unbeaten in all competitions but three costly errors from goalkeeper Alisson Becker cost them dear.
Elsewhere in the English top flight, Antonio Conte had a taste of the scale of his task at new club Tottenham as they laboured to a 0-0 draw at Everton.
Liverpool travelled to the London Stadium without a defeat since April but left frustrated as West Ham leapfrogged them into third spot in the table.
It was a day to forget for Brazilian international Alisson, whose own goal put West Ham ahead early in the first half.
Trent Alexander-Arnold equalised with a brilliant free-kick, but Alisson was at fault again as Pablo Fornals and Kurt Zouma struck for the Hammers after half-time.
Divock Origi pulled one back for Liverpool, but it was not enough to preserve their long unbeaten streak and they stay four points behind leaders Chelsea.
“However long a run is, it will come to an end,” said Klopp, who was disappointed with some of the refereeing decisions.
“It looked like we lost a bit of patience. We were not that calm in the decisive moments. We can be better, 100%.”
West Ham boss David Moyes said finishing in the Champions League places was realistic after they narrowly missed out last season.
“This result shows that we’re really in with a good chance of challenging for the top places,” he told the BBC.
“I’m hugely proud (that I’ve turned West Ham around). The way the players have gone about it, you talk about me turning it around. These players were close to relegation, now we’re pushing for Europe.”
Spurs sacked Nuno Espirito Santo last week after five defeats in seven Premier League matches and turned to Conte, who has won league titles with Juventus, Chelsea and Inter Milan.
A game short on clear-cut chances could easily have ended in another league defeat for the visitors but for an intervention from VAR to overturn the decision to award Everton a second-half penalty.
Rafael Benitez’s side thought they had won a spot-kick after Spurs goalkeeper Hugo Lloris dived at the feet of Richarlison and clipped the Brazilian.
But after a VAR review referee Chris Kavanagh overturned his original decision on the basis that Lloris got enough of a touch on the ball.
Mason Holgate was sent off for the home side in stoppage time but it was too late for Spurs to take advantage.
Conte can point to a first clean sheet in the league since August as a sign of progress but Tottenham’s struggle to score goes on, with Harry Kane still stuck on one goal in the Premier League this season.
“Today I saw the heart of my players, the passion, the will to fight, the will to sacrifice, to understand this was a very difficult moment for us and to see this makes me more confident for the future,” said the Italian.
Mikel Arteta celebrated his 100th game as Arsenal manager with a 1-0 victory against 10-man Watford, courtesy of a goal from Emile Smith Rowe.
Leeds and Leicester shared the spoils in a 1-1 draw after a stunner from Harvey Barnes cancelled out Raphinha’s opener.
Earlier, Villa announced they had sacked manager Smith after five straight Premier League defeats - less than 24 hours after bottom club Norwich dismissed their boss, Daniel Farke.
The former European champions are now 16th in the Premier League table after picking up just 10 points from their opening 11 games.
“This year we have not seen the continuous improvement in results, performances and league position which we have all been looking for,” Villa chief executive Christian Purslow said in a statement on the club’s website.
Smith is the fifth managerial casualty in the Premier League this season.