For a manager of Rafael Benítez’s pragmatism, it is unlikely that this chaotic game fitted into his vision of how football should be played. Sometimes, though, getting the job done matters more than questions of philosophy and even Benítez could put his obsession with control to one side after Newcastle clambered out of the relegation zone thanks to their first victory in 10 matches.

The Spaniard could not allow the celebrations to last too long, though, even after seeing his players ensure that the team in the famous black and white stripes would not spend Christmas Day in the bottom three for the first time in Premier League history. Ever the perfectionist – or, perhaps, ever the politician – Benítez made a point of stressing that Mike Ashley still needs to reach for his wallet when the transfer window opens, saying that Newcastle’s survival hopes remain dependent on bringing in additional quality next month.

This gutsy performance was not enough to convince Benítez that the worst is over. Newcastle are only two points above the bottom three and they had to ride their luck at times, with Rob Elliot’s save from André Ayew’s tame penalty preventing West Ham from making it 2-2 moments after Mohamed Diamé had put visitors in front. Better opponents might have punished their sloppy defending.

On the balance of play, however, it was difficult to argue that Newcastle were undeserving winners over West Ham, whose revival under David Moyes came to a messy end on a manic afternoon. Marko Arnautovic’s early opener counted for nothing in the end as the home side tumbled to 17th after Henri Saivet and Christian Atsu scored either side of Diamé’s strike. “Totally error‑strewn game,” Moyes said. “We should have capitalised. We didn’t perform well enough.”

The madness began when Saivet, making his first Premier League start of the season, inexplicably sent a simple pass straight to Arnautovic in the sixth minute. Arnautovic burst forward from the halfway line, with Ciaran Clark exposed, and the Austrian displayed his new found confidence by swerving to the centre-back’s left before clipping a fine shot past Elliot.

Yet West Ham were unable to build on Arnautovic’s third goal in his past four games. Saivet, who was having an eventful start, equalised four minutes later. Winston Reid caught Atsu and the Senegalese took advantage of a questionable wall by whipping a low free-kick beyond the cumbersome Adrián.

The chances kept coming. Michail Antonio spurned two free headers, yet West Ham stuttered in midfield without Manuel Lanzini, who was serving the last match of his retrospective ban for diving, and Newcastle were aggrieved not to be ahead at the interval.

DeAndre Yedlin’s combinations with Matt Ritchie caused plenty of problems down Newcastle’s right. Ritchie curling shot from 20 yards struck a post and the winger created two excellent opportunities for Dwight Gayle, who crashed one against the bar before wastefully scooping the other over.

Arnautovic came close to restoring West Ham’s lead shortly after half-time, whipping a shot inches wide from 18 yards. Yet Newcastle were playing with impressive belief and the second goal they had been threatening arrived in the 53rd minute. Atsu skipped past Pablo Zabaleta, nutmegging the defender for good measure, and his cutback found Diamé, whose finish against his former side was emphatic.

Then came a moment of controversy, Antonio latched on to a loose ball and Clark lunged to bring the forward down. Lee Mason, the referee, initially awarded a free-kick, only to point to the spot on the advice of his assistant. “I was watching the replay and I think it is outside,” Benítez said. “The referee was pointing for a foul more than a penalty.”

However, Ayew stepped up in the absence of the injured Mark Noble and Elliot made a straightforward save from his casual effort. “We’ve missed one at Everton and here,” Moyes said. “It’s hard enough to get the chances.”

That was the turning point. Newcastle broke from a West Ham corner, slicing through the home team’s wheezing back three at will, Joselu teeing up Atsu to beat Adrián from close range.

West Ham refused to lie down and Ayew made up for his earlier profligacy when he pounced after a corner caused confusion in the Newcastle area in the 69th minute. The visitors would not be denied, however, and the noisy travelling supporters finally had something of substance to celebrate.