The Hammers 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 in the build-up to the opener.
West Ham finally snapped into gear as Diop made amends and Jesse Lingard scored from the penalty spot, only for Joe Willock to head in a late winner for Newcastle.
To compound the Hammers’ misery, Lingard was forced off late on with an injury.
The result means the Hammers missed the chance to go third and will find themselves in sixth should Chelsea and Liverpool win their games in hand in midweek.
Newcastle move nine points clear of the relegation zone after back-to-back wins.