Adama Traore scored the only goal in added time to earn Wolverhampton Wanderers their first victory since returning to the Premier League.
Diogo Jota had the best chance of the first half for Wolves, but could only head Joao Moutinho's cross over the bar.
West Ham's Michail Antonio and Marko Arnautovic were both denied by Rui Patricio's excellence after the break.
But club-record signing Traore struck the winner in the third minute of stoppage time, firing low beneath Lukasz Fabianski for his first Premier League goal.
Wolves' win lifts them to ninth.
West Ham's fourth Premier League defeat from four this season leaves them bottom of the table.
See: West Ham report | Wolves report
Next fixtures
West Ham: 16 Sep v Everton (A)
Wolves: 16 Sep v Burnley (H)