West Ham United's top-four hopes were dealt a big blow as Joe Willock's late header earned Newcastle United a 3-2 win in a see-saw clash on Saturday - a result that put the host within sight of Premier League safety.
The London club capitulated in the first half with an Issa Diop own goal and a Lukasz Fabianski blunder that allowed Joelinton to give Newcastle a 2-0 lead at the interval, while West Ham also had Craig Dawson sent off.
But the second half saw the London side produce a stunning revival.
Diop scored at the right end to give West Ham hope in the 73rd minute, and Jesse Lingard then converted a penalty to make it 2-2 with little under 10 minutes remaining. But there was a final cruel twist for the visitor as Newcastle substitute Willock headed home a late winner.
West Ham could not respond again. The loss means they stay in fourth place on 55 points from 32 games, one point above Chelsea and three above Liverpool, both of whom have a game in hand.
Newcastle's second successive win after going seven games without one lifts them nine points clear of third-from-bottom Fulham and up into relative safety of 15th place.
West Ham's unlikely challenge for a Champions League place has been a rollercoaster ride in recent weeks, and Saturday proved no exception.
In their previous three games West Ham had taken 3-0 leads in a 3-3 draw with Arsenal and 3-2 wins over Wolverhampton Wanderers and Leicester City.
At St James' Park they reversed the pattern.
Nothing much happened for 36 minutes until Dawson, who had already been booked, lunged into a tackle after a poor touch. The ball broke for Allan Saint-Maximin, who advanced towards goal and released a weak shot that somehow got through Fabianski and Diop, with the ball going in off the French centre back.
Referee Kevin Friend then went back to give Dawson his marching orders for the tackle in the buildup.
Things went from dreadful to calamitous for West Ham five minutes later as Fabianski inexplicably dropped a routine corner and Joelinton pounced to sweep home.
West Ham were much-improved after the break, despite their numerical disadvantage, and Diop gave them a lifeline when he headed past Martin Dubravka.
Newcastle retreated further and further, and a few minutes later Ciaran Clark's raised arm made contact with the ball as he challenged Tomas Soucek for a header.
Friend was instructed to check the incident on a VAR monitor and pointed to the spot. Lingard slotted home for his ninth goal for the club since joining on loan from Manchester United.
West Ham looked capable of claiming an amazing victory, but Newcastle responded immediately. First Jacob Murphy had a shot cleared off the line by Ben Johnson before Willock, who had only just come on, headed powerfully past Fabianski.