The result came as a result of a catastrophic first-half error by goalkeeper David De Gea, who let a weak shot from Said Benrahma squirm past him in the 27th minute after his team had largely dominated the opening period.
United had been boosted by Arsenal's earlier 2-0 win at third-placed Newcastle, but their loss to West Ham leaves them in fourth place, just one point ahead of Liverpool, who have played a game more.
The result puts United's season in a precarious position as they have now suffered two straight league defeats.
Despite De Gea's costly mistake, Manchester United manager Erik ten Hag defended his beleaguered goalkeeper and said his team still had control of their destiny this season with four league games left to play.
"Mistakes are part of football and in this team, you have to deal with it and bounce back because it is a team sport," the United manager told BT Sport.
West Ham, who play in the Europa Conference League semifinals this week, are now seven points clear of the relegation zone.
They took the lead against the run of play when Benrahma's weak shot from distance somehow squirmed past the sprawling De Gea.
The Hammers' victory came as a huge boost to their hopes of survival this season.
United started brightly with top-scorer Marcus Rashford hitting the outside of the post in the 17th minute.
But despite having the majority of the possession, United's attack was largely ineffective in front of the goal.
As the clock ticked down to halftime, De Gea denied Benrahma a second before a huge penalty appeal for handball against Victor Lindelof was waved away by referee Peter Bankes.
West Ham had the ball in the net again early in the second half but the goal was ruled out for offside.
Ten Hag's men tried to bounce back in the second half, with Jadon Sancho and Marcel Sabitzer being thrown on, but they could not find a way back into the game.
West Ham boss David Moyes praised the "huge character of his side", saying it would be tough for teams below them to catch them, even though they are not mathematically safe.
"The number isn't confirmed that it keeps you in the Premier League, so we have to look forward to the next game and try and pick up more points," he said.