Marko Arnautovic put the Hammers ahead on six minutes, firing past Rob Elliot.
Henri Saivet levelled for Newcastle just four minutes later with a superb free-kick.
Mohamed Diame put the visitors ahead on 53 minutes from Christian Atsu's cross, before Atsu finished off a counter-attack to make it 3-1.
Andre Ayew drilled in after Andy Carroll’s header had been saved to make it 3-2 on 69 minutes, but Newcastle held on for three points that raised them above their opponents to 15th.
West Ham: 26 Dec v AFC Bournemouth (A)
Newcastle: 27 Dec v Man City (H)