The England striker had been ruled out for a month with a serious injury earlier this week - but defied Red Devils doctors to make an incredible return to fitness, playing the full 90 minutes against the Hammers.
Danny Welbeck and Adnan Januzaj both finished well after good build-up play to put the hosts 2-0 up and in charge at half-time.
Moments after coming off the bench, Ashley Young smashed home a beauty, his second goal in as many games after a terrible slump in form.
Carlton Cole pulled back a late consolation after fellow sub Alexander Buttner played him onside, but United were home and dry anyway as they closed out victory.
The result puts United up a place to seventh, eight points behind leaders Liverpool, with Arsenal and Chelsea yet to play.
The Hammers, meanwhile, hover uncomfortably above the bottom three, only clear of the drop zone because Fulham and Crystal Palace both lost.
PRE-MATCH – Rooney starts: Despite having been ruled out for a month, Wayne Rooney makes a miraculous recovery and plays 90 minutes in a deep-lying role. He plays well too.
2’ – SAVE: Adrian with a superb reflex stop to claw out Tom Cleverley’s goal-bound finish.
26’ – GOAL (Manchester United 1-0 West Ham): Adrian should have done better to keep out Welbeck’s low finish, but the combination with Wayne Rooney to create the chance was excellent.
36’ – GOAL (Manchester United 2-0 West Ham): Januzaj completes a one-two with Welbeck before cutting inside James Collins and brilliantly firing past Adrian.
41’ – DIVE: Januzaj shows a darker side to his game with a hilariously blatant dive over Collins’ leg. Clear booking.
48’ – CHANCE: Brilliant cross by Januzaj that Welbeck is inches away from converting. Fantastic swerving low ball by the Belgian.
72’ – GOAL (Manchester United 3-0 West Ham): Just after coming on, Young meets a Rooney cut-back with a vicious first-time shot into the top right. Excellent goal.
81’ – GOAL (Manchester United 3-1 West Ham): Cole cannot believe it as he is allowed to amble clean through and knock it past David De Gea. Buttner at fault for not holding any kind of line.
90’ – CHANCE: Javier Hernandez kicks air with just the keeper to beat. The last person you’d expect to be guilty of such a miss.
Are United back on track? After their dreadful run was capped off by back-to-back home defeats, United have now won four in a row, although they will be disappointed at the manner of the goal they conceded.
Manchester United have lost none of the last 10 league games against West Ham, winning nine and drawing one.
Manchester United have not lost three successive home league games since Dec 1978 - Feb 1979.
The Hammers have won just one of their nine Premier League away games this season (D3 L5), failing to score five times.
MAN OF THE MATCH
Phil Jones (Manchester United) – A dominant performance in central midfield, as Jones continually broke up attacks and launched counters with surging runs. Is this his best position?
Manchester United: De Gea 6, Rafael 6, Smalling 6, Evans 7, Evra 6, Valencia 6, Jones 8, Cleverley 7, Januzaj 7, Welbeck 7, Rooney 7; Subs: Hernandez 6, Young 7, Büttner 5
West Ham: Adrian 5, Demel 6, Tomkins 6, Collins 5, McCartney 5, Noble 6, Morrison 5, Taylor 5, Jarvis 5, Maiga 6, Diame 6; Subs: Rat 6, Collison 6, C.Cole 6
MATCH IN A TWEET