Newcastle halted their alarming slide and ended West Ham's recent revival by edging a five-goal thriller 3-2 at the London Stadium.
Marko Arnautovic gave the Hammers, who had a spring in their step following recent wins over Chelsea and Stoke, a sixth-minute lead.
But the wheels fell off spectacularly as Newcastle raced ahead through goals from forgotten midfielder Henri Saivet, Mohamed Diame and Christian Atsu.
Andre Ayew, who had earlier missed a penalty, pulled one back but Newcastle held on for victory, their first win in 10 matches, to ensure they will not spend Christmas in the bottom three.
The first 10 minutes of an often barmy match were simply the Saivet show, remarkable given the Senegal midfielder had barely been seen in almost two years - his last league appearance for the Magpies was in February 2016.
Saivet made an immediate impact, although not the desired one when he gifted the ball to Arnautovic in the centre of the pitch.
The Austrian still had plenty to do as he charged from the halfway line, but he outstripped lone defender Ciaran Clark before slotting past Rob Elliot for a third goal in four matches.
However, Saivet redeemed himself almost immediately, lifting a 25-yard free-kick over the West Ham wall and inside Adrian's near post to bring his side level after 10 minutes.
Newcastle were then twice denied by the woodwork, Dwight Gayle seeing his effort crash back off the crossbar and Matt Ritchie curling against a post.
The back five which had earned West Ham three successive clean sheets was suddenly not looking quite so robust and Gayle passed up another chance when he sidefooted Javier Manquilo's cross off target.
Solid defending has hardly been Newcastle's strong suit either, and Michail Antonio should have done better with the free header he planted wide before the interval.
Eight minutes after the break Newcastle forged ahead through a familiar face in east London.
Atsu raced past Pablo Zabaleta and his low cross was met with an emphatic finish from former Hammers midfielder Diame.
Moments later West Ham were gifted the chance of an equaliser when Clark fouled Antonio in the area.
In the absence of regular penalty taker Mark Noble, Ayew stepped up but his his stuttering run-up was followed by a weak penalty which was palmed away by Elliot.
Buoyed by their let-off, and helped by some comical defending between Zabaleta and Arthur Masuaku, Newcastle doubled their lead when Astu raced clear and exchanged pases with Joselu before tucking away the third.
With 20 minutes left Ayew, woeful from 12 yards, showed he is still deadly from two as he snaffled the rebound after Elliot had blocked substitute Andy Carroll's header.
West Ham piled forward looking for an equaliser but Newcastle held firm to record a much-needed first win since October for manager Rafael Benitez.