Newcastle made the perfect start when Alexander Isak converted from the penalty spot in the third minute, but West Ham responded well and entered half time in front courtesy of goals from Michail Antonio and Mohammed Kudus.
Jarrod Bowen then increased the Hammers' lead just three minutes after the interval, but the Magpies admirably sparked a memorable comeback, scoring three goals in the final 13 minutes to snatch maximum points in dramatic fashion.
Isak netted his second penalty of the contest shortly before substitute Harvey Barnes scored twice in the closing stages, firstly slotting a composed finish under the legs of Lukasz Fabianski before curling a sensational 20-yard strike into the far corner in the 90th minute, sparking bedlam among the St James' Park faithful.
Newcastle have climbed to eighth in the Premier League table, at the time of writing, and sit just one point behind seventh-placed West Ham, who have played a game more.
Newcastle trio join growing injury list
However, Newcastle's victory came at a cost as Jamaal Lascelles, Valentino Livramento and Miguel Almiron were all forced off with injuries, while Anthony Gordon was sent off in stoppage time for two bookable offences and will subsequently miss next Tuesday's clash against his former club Everton.
Lascelles went down with a knee injury early in the first half and attempted to carry on, but the centre-back eventually hobbled off in the 18th minute, with Emil Krafth brought on as his replacement.
Livramento, who switched from right-back to left-back following the introduction of Krafth, was the next to make way on the 56-minute mark after rolling his ankle.
Almiron replaced Livramento and made a lively introduction against the Hammers, but the winger was on the pitch for just 11 minutes before coming off with a knee problem.
All three players now join a lengthy injury list including Sven Botman (ACL), Callum Wilson (pectoral), Joelinton (thigh), Nick Pope (shoulder), Kieran Trippier (calf) and Lewis Miley (back).
Eddie Howe: 'Injuries have been the story of our season'
Speaking to reporters after the game about Newcastle's injury crisis, Howe said: "It's been the story of our season. Unfortunately, we were getting hit left, right and centre today. We were 1-0 up, and then Jamaal goes off. Miggy (Almiron) goes off, Anthony is sent off and Tino (Livramento) goes off.
"It is a catalogue, one after another, but the players we brought on made a positive impact, and that's the beauty of our squad."
Howe continued: "Jamaal has a knee problem but I don't know any more than that. I think the ball hit Tino's ankle so it's an ankle twist and Miggy hurt his knee crossing a ball."
The Magpies boss has also confirmed that the withdrawal of Krafth midway through the second half was a tactical one, adding: "No, that wasn't an injury. I wanted to get as many attacking players on the pitch as I could."
Howe is set to provide a fresh update on the fitness of his Newcastle squad when he addresses the media at a press conference on Monday ahead of Tuesday's top-flight clash with Everton.