Steve Bruce's side doubled their lead five minutes later, after a failed catch from a corner from Lukasz Fabianski seen the ball fall directly in front of Joelinton who slammed home from point-blank range.
But two quick-fire goals after the interval from the visitors, courtesy of Diop and a penalty from Jesse Lingard pulled the man-down visitors level with just ten minutes to go.
Story of the game
David Moyes made two changes from his sides impressive 3-2 home victory over fellow Champions League chasers Leicester – with Ben Johnson coming in for the injured Aaron Cresswell, as well as a first appearance in eight matches for Angelo Ogbonna.
After an opening five-or-so minutes that were dictated by the visitors, it was Newcastle who had the first real opportunity of the game. Miguel Almiron darted from the left-hand side and worked space to play the ball into the path of Sean Longstaff on the edge of the box who found space to shoot, but it took a deflection and dragged wide of the goal.
The hosts grew into the game as it went on, and on 14 minutes, Jacob Murphy forced a solid save from Lukasz Fabianski in the West Ham goal at his near post.
The chances kept coming for Newcastle, but they could not get their noses in front. Saint-Maximin latched onto the ball on the edge of the penalty area and drove it towards goal, but Fabianski got low and was able to catch the strike.
Saint-Maximin continued to be a nuisance on the 28-minute mark as he cut through the middle of the West Ham midfield, worked space to get a shot off but the solid Hammers back-line were able to get a block on the effort to avert it away from danger.
On 36-minutes Newcastle's attacking perseverance paid off as they went a goal up, and a man up. Craig Dawson – who was booked earlier in the game – fouled Joelinton and was subsequently given his marching orders, not before Saint-Maximin got through on goal, and courtesy of Issa Diop getting his legs tangled on the goal-line, it found its way into the back of the net.
And just five minutes later, they doubled their advantage, thanks to more self-inflicted damage from their opponents. Newcastle swung a corner in, the ball was going directly into the hands of Fabianski – but he dropped it directly in front of Joelinton who notched the ball home from point-blank range.
It almost got worse for The Hammers right on the stroke of half-time as Joelinton latched onto a Saint-Maximin ball, worked space in the box to shoot, but his effort was time and Fabianski – this time – was able to gather the ball.
A rallying West Ham fightback, but Newcastle bounced back and snatched all the points
The visitors had a mountain to climb after the interval – but started bright – and Jarrod Bowen forcing a good save out of Martin Dubravka signified that.
West Ham continued to dominate the second half and probably should have pulled a goal back. Jesse Lingard went close with a few chances from distance before a towering header from Ogbonna flashed past the post.
The Hammers were knocking on the door and had a massive opportunity go begging as Johnson played an inch-perfect ball into the path of Vladimir Coufal whose header from six yards out was straight at Dubravka.
On 73-minutes, West Ham finally got their foothold back in the game. Newcastle switched off from a throw-in and Bowen's cross found Diop perfectly, who headed – this time into the correct net – past Dubravka.
West Ham were then awarded a penalty on the stroke of 80 minutes after a lengthy VAR check which deemed Ciaran Clark had handled the ball in the penalty area. Lingard stepped up and made no mistake from the spot to pull the ten-men level.
The Hammers – prior to their penalty – took midfielder and captain Mark Noble off and brought off a forward in Said Benrahma. It was evident – especially with ten-men – that West Ham were outnumbered in midfield, with just Tomas Soucek operating the middle of the park.
Newcastle tried to take advantage of that, and if it was not for a superb goal-line clearance by Johnson to deny Jacob Murphy, the hosts would have had their noses in front.
But The Magpies did not have to wait long to retake the lead – a pinpoint cross from Matt Ritchie found the cushioned head of substitute Joe Willock who arrowed the ball into the roof of the net.
Newcastle held out a nervy eight minutes of added time to seal back-to-back victories, which sees them move nine points clear of the bottom three.
Newcastle now look very good to beat the drop
2-0 up at half-time against ten-men, surely Newcastle just grab another goal and see the game out comfortably?
No. They looked instead to protect their lead and sit deep against a West Ham side that are full of goals.
And despite being pegged back by the visitors just ten minutes from time – fortunately for them, they found a late winner.
But my goodness did they make a match that looked like a foregone conclusion at the interval so difficult for themselves.
If you told Newcastle fans at the start of March that they would be nine points clear of 18th placed Fulham with just six games to go, they probably would have laughed at you.
It is no real surprise, however, that Allan Saint-Maximin's recent return from injury has greeted The Magpies with six points out of a possible six in the games he has been involved in – two results that have put Steve Bruce's side in a commanding position to survive relegation.
The Frenchman was once again head and shoulders above every player on the pitch, and if they were able to keep him – along with Callum Wilson – fit for the entire season, it does make you wonder how high Newcastle actually would be in the Premier League table.
West Ham miss a big opportunity to move into the top three
It was a case of self-inflicted wounds for West Ham today which lead to them leaving St James' Park with absolutely nothing.
A tangling of legs for the opener, shortly followed by a red card, and then a clanger from Fabianski for the second goal – all of this within the opening 45 minutes.
But after the interval – and mainly down to their opponents happy to invite pressure on – they played like the West Ham we are now accustomed to this season, and managed to get the game level, despite being down to ten-men.
The decision to take Noble off for Benrahma just before the penalty proved to be costly for The Hammers, as they were left outnumbered in the midfield when they were trying to hold on for a point from a game that looked beyond them at half-time.
This defeat – to a relegation-threatened side – is undoubtedly a big blow to West Ham's hopes of playing in the Champions League next season, especially when you look at the quality of the teams directly below them.
Newcastle United: Dubravka; Murphy, Fernandez, Clark, Dummett, Ritchie; Shelvey, Longstaff; Almiron; Saint-Maximin, Joelinton. (5-2-1-2)
West Ham United: Fabianski; Diop, Dawson, Ogbonna; Coufal, Noble, Soucek, Johnson; Fornals; Bowen, Lingard. (3-4-1-2)