Edinson Cavani crossed for fellow substitute Rashford to score in front of a rocking Stretford End.
Super-sub Marcus Rashford struck a dramatic stoppage-time winner as Manchester United broke West Ham hearts and lifted the roof off Old Trafford.
In the Carabao Cup earlier in the season David Moyes led the Hammers to their first win at the Red Devils since 2007 and he looked set to leave with a potentially vital point in the race for Champions League qualification.
But United dug deep and secured victory with virtually the last kick of the game as Edinson Cavani crossed for fellow substitute Rashford to score in front of a rocking Stretford End to seal a 1-0 win.
It was a memorable end to what looked set to end in a drab goalless draw between two sides that failed to muster a shot on target between them in the first half.
Cristiano Ronaldo went close to connecting a with a fine cross and saw penalty appeals ignored in that opening period, with Ralf Rangnick throwing caution to the wind with his late attacking substitutions.
West Ham nearly capitalised as they pushed top-heavy United, only for the stars to align as Rashford turned home.
After a video assistant referee review for offside, the goal was awarded as Rangnick celebrated consecutive wins for the first time in charge.