Crystal Palace s Wilfried Zaha, center, in action with West Ham United s Kurt Zouma, left, and Craig Dawson during the English Premier League soccer match at the London Stadium, London, Sunday Nov. 6, 2022. AP
Michael Olise struck in the fourth minute of added time to secure the crucial win.
The late goal completed a comeback by the visitors after Said Benrahma had fired West Ham in front in the first half and Wilfried Zaha equalized.
Olise's winner came after West Ham saw a penalty overturned late in the game when referee Paul Tierney reviewed an incident involving Marc Guehi on Michail Antonio and reversed his decision.
That paved the way for late drama, with Olise's effort taking a heavy deflection off Aaron Cresswell and looping past Lukasz Fabianski in the West Ham goal.
The defeat snapped West Ham's six-match winning streak at home, while Palace secured a first away win in the Premier League this season.
West Ham went ahead in style after Benrahma unleashed a drive past Vicente Guaita.
It was a glorious strike but the West Ham defence undid all his good work with a horror show five minutes before half-time.
There was no danger as Fabianski rolled the ball to Craig Dawson, who in turn sent it towards Thilo Kehrer on the right wing.
But the Germany international lost the ball to Eberechi Eze and Zaha outmuscled Dawson before lashing the ball past Fabianski.
Olise's late strike then sealed the win.