Louis van Gaal's side knew victory here and at home to Bournemouth this weekend would secure a top-four place - but this loss means Manchester City are two points clear of them going into their final game at Swansea City.
The visitors' team coach arrived late and was attacked by Hammers fans as it made its way into the stadium, causing the kick-off to be delayed.
When the action got under way West Ham dominated and should have led by more than Diafra Sakho's goal at the break.
Antony Martial turned the game on its head and had Manchester United in charge with only 18 minutes remaining, first ending a sweeping move then beating Darren Randolph at his near post to put the visitors ahead.
West Ham, however, were not to be denied and two towering headers in the space of four minutes from Michail Antonio and Winston Reid gave them the victory they richly deserved.